add_filter( 'template_include', 'portfolio_page_template', 99 );
function portfolio_page_template( $template ) {
if( is_page('portfolio') ){
if ( $new_template = locate_template( array( 'portfolio-page-template.php' ) ) )
$template = $new_template ;
}
return $template;
}
<?php
namespace Oxboot\Theme;
use Brain\Hierarchy\Hierarchy;
use duncan3dc\Laravel\BladeInstance;
use Twig_Loader_Filesystem;
use Twig_Environment;
class View
{
public function __construct($config)
{
add_action('template_redirect', function () use ($config) {
$templates = (new Hierarchy())->getTemplates();
$template_engines = $config['view']['template_engines'];
foreach ($templates as $template) {
foreach ($template_engines as $template_engine => $template_extension) {
$path = OX_THEME_VIEWS."/{$template}{$template_extension}";
if (file_exists($path)) {
switch ($template_engine) {
case 'Blade':
$blade = new BladeInstance(OX_THEME_VIEWS, OX_THEME_CACHE.'/blade');
echo $blade->render($template);
break;
case 'Twig':
$loader = new Twig_Loader_Filesystem(OX_THEME_VIEWS);
$twig = new Twig_Environment($loader, ['cache' => OX_THEME_CACHE.'/twig']);
echo $twig->render($template.$template_extension);
break;
case 'PHP':
require $path;
}
exit;
}
}
}
});
}
}
<?php
$g = stream_context_create (array("ssl" => array("capture_peer_cert" => true)));
$r = fopen("https://www.google.com/", "rb", false, $g);
$cert = stream_context_get_params($r);
$certinfo = openssl_x509_parse($cert['options']['ssl']['peer_certificate']);
echo "Certificate info: <pre>". print_r($certinfo, true) ."</pre>";
function parse_gallery_images($content) {
$attachment_ids = [];
$pattern = get_shortcode_regex();
$images = [];
if (preg_match_all( '/'. $pattern .'/s', $content, $matches ) ) {
//finds the "gallery" shortcode and puts the image ids in an associative array at $matches[3]
$count = count($matches[3]); //in case there is more than one gallery in the post.
for ($i = 0; $i < $count; $i++){
$atts = shortcode_parse_atts( $matches[3][$i] );
if ( isset( $atts['ids'] ) ){
$attachment_ids = explode( ',', $atts['ids'] );
$attachementsCount = count($attachment_ids);
if ($attachementsCount > 0){
for ($j = 0; $j < $attachementsCount ; $j++) {
$image = [];
$attachmentId = intval($attachment_ids[$j]);
$image['id'] = $attachmentId;
$image['full'] = wp_get_attachment_image_src($attachmentId, 'full');
$image['medium'] = wp_get_attachment_image_src($attachmentId, 'medium');
$image['thumbnail'] = wp_get_attachment_image_src($attachmentId, 'thumbnail');
array_push($images, $image);
}
}
}
}
}
return $images;
}