: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
} elseif ( 'portfolio.php' === basename( get_page_template() ) || ( ! empty( $prtfl_options['page_id_portfolio_template'] ) && $post->ID === $prtfl_options['page_id_portfolio_template'] ) ) {
global $wp_query, $request, $pdfprnt_options_array, $pdfprnt_options;
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var( 'page' );
$per_page = get_option( 'posts_per_page' );
$technologies = isset( $wp_query->query_vars['technologies'] ) ? $wp_query->query_vars['technologies'] : '';
$executor_profile = isset( $wp_query->query_vars['portfolio_executor_profile'] ) ? $wp_query->query_vars['portfolio_executor_profile'] : '';
if ( '' !== $technologies ) {
'post_type' => $prtfl_options['post_type_name'],
'post_status' => 'publish',
'orderby' => $prtfl_options['order_by'],
'order' => $prtfl_options['order'],
'posts_per_page' => $per_page,
'taxonomy' => 'portfolio_technologies',
'terms' => $technologies,
} elseif ( '' !== $executor_profile ) {
'post_type' => $prtfl_options['post_type_name'],
'post_status' => 'publish',
'orderby' => $prtfl_options['order_by'],
'order' => $prtfl_options['order'],
'posts_per_page' => $per_page,
'taxonomy' => 'portfolio_executor_profile',
'terms' => $executor_profile,
'post_type' => $prtfl_options['post_type_name'],
'post_status' => 'publish',
'orderby' => $prtfl_options['order_by'],
'order' => $prtfl_options['order'],
'posts_per_page' => $per_page,
$second_query = new WP_Query( $args );
$request = $second_query->request;
if ( $second_query->have_posts() ) {
while ( $second_query->have_posts() ) {
$second_query->the_post();
$custom_content .= '<div class="portfolio_content entry-content">
$post_meta = get_post_meta( $post->ID, 'prtfl_information', true );
$user_id = get_current_user_id();
$short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : '';
if ( empty( $short_descr ) ) {
$short_descr = get_the_excerpt();
$title = get_the_title();
$title = '(' . __( 'No title', 'portfolio' ) . ')';
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
if ( empty( $post_thumbnail_id ) ) {
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
$attachments = get_children( $args );
$post_thumbnail_id = key( $attachments );
if ( ( isset( $pdfprnt_options_array['show_featured_image'] ) && 1 === absint( $pdfprnt_options_array['show_featured_image'] ) )
|| ( isset( $pdfprnt_options['show_featured_image'] ) && 1 === absint( $pdfprnt_options['show_featured_image'] ) ) ) {
$image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] );
if ( ! empty( $image[0] ) ) {
/* get width and height for image_size_album */
if ( 'portfolio-thumb' !== $prtfl_options['image_size_album'] ) {
$width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) );
$height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) );
$width = $prtfl_options['custom_size_px']['portfolio-thumb'][0];
$height = $prtfl_options['custom_size_px']['portfolio-thumb'][1];
$image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
$custom_content .= '<div class="portfolio_thumb"><img src="' . $image[0] . '" width="' . $width . '" height="' . $height . '" style="width:' . $width . 'px; height:' . $height . 'px;" alt="' . $image_alt . '" /></div>';
$custom_content .= '<div class="portfolio_short_content">
<p><a href="' . get_permalink() . '" rel="bookmark">' . $title . '</a></p>
if ( 1 === absint( $prtfl_options['date_additional_field'] ) ) {
$date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : '';
if ( ! empty( $date_compl ) ) {
$custom_content .= '<p><span class="lable">' . $prtfl_options['date_text_field'] . '</span> ' . $date_compl . '</p>';
if ( 1 === absint( $prtfl_options['link_additional_field'] ) && ! empty( $post_meta['_prtfl_link'] ) ) {
if ( false !== wp_parse_url( $post_meta['_prtfl_link'] ) ) {
if ( ( 0 === $user_id && 0 === absint( $prtfl_options['link_additional_field_for_non_registered'] ) ) || 0 !== $user_id ) {
$custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> <a href="' . $post_meta['_prtfl_link'] . '">' . $post_meta['_prtfl_link'] . '</a></p>';
$custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>';
$custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>';
if ( 1 === absint( $prtfl_options['shrdescription_additional_field'] ) ) {
$custom_content .= '<p><span class="lable">' . $prtfl_options['shrdescription_text_field'] . '</span> ' . $short_descr . '</p>';
$custom_content .= '</div>
return $content . $custom_content;
if ( ! function_exists( 'prtfl_add_portfolio_ancestor_to_menu' ) ) {
* Adding class to manu items
* @param array $classes Array with classes.
* @param object $item Post object.
* @return array $classes Array with classes.
function prtfl_add_portfolio_ancestor_to_menu( $classes, $item ) {
if ( is_singular( $prtfl_options['post_type_name'] ) ) {
$parent = $wpdb->get_var( "SELECT $wpdb->posts.post_name FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'portfolio.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id" );
if ( in_array( 'menu-item-' . $item->ID, $classes ) && strtolower( $item->title ) === $parent ) {
$classes[] = 'current-page-ancestor';
if ( ! function_exists( 'prtfl_latest_items' ) ) {
* Forming content for portfolio items
* @param array $atts Attributes.
* @param array $count Count or false.
function prtfl_latest_items( $atts, $count = false ) {
global $prtfl_options, $wp_query;
if ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) {
$old_wp_query = $wp_query;
$count_portfolio_row_block = 0;
if ( false === $count || empty( $count ) ) {
$custom_portfolio_row_count = $prtfl_options['custom_portfolio_row_count'];
$custom_portfolio_row_count = $count;
$prtfl_widht = 100 / $custom_portfolio_row_count;
if ( 1 < $custom_portfolio_row_count ) {
$prtfl_img_width = 'style="width:165px"';
$content = '<div class="prtfl_portfolio_block">';
if ( empty( $atts['count'] ) ) {
'post_type' => $prtfl_options['post_type_name'],
'post_status' => 'publish',
'order' => $prtfl_options['order'],
'posts_per_page' => $atts['count'],
$second_query = new WP_Query( $args );
$request = $second_query->request;
if ( $second_query->have_posts() ) {
while ( $second_query->have_posts() ) {
$second_query->the_post();
if ( 0 === $count_portfolio_row_block % $custom_portfolio_row_count ) {
$content .= '<div class="portfolio_row_count">';
$content .= '<div id="portfolio_row_count_block" class="portfolio_row_count_block" style="width: ' . $prtfl_widht . '%">
<div class="portfolio_content">
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
if ( empty( $post_thumbnail_id ) ) {
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
$attachments = get_children( $args );
$post_thumbnail_id = key( $attachments );
$image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] );
$image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
$image_desc = get_post( $post_thumbnail_id );
$image_desc = $image_desc->post_content;
$post_meta = get_post_meta( $post->ID, 'prtfl_information', true );
$date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : '';
$link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : '';
$short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : '';
if ( empty( $short_descr ) ) {
$short_descr = get_the_excerpt();
$title = get_the_title();
$title = '(' . __( 'No title', 'portfolio' ) . ')';
$permalink = get_permalink();
$content .= '<div class="portfolio_thumb" ' . $prtfl_img_width . '>
<img src="' . $image[0] . '" width="' . $image[1] . '" alt="' . $image_alt . '" />
<div class="portfolio_short_content">
<a href="' . $permalink . '" rel="bookmark">' . $title . '</a>
</div> <!-- .item_title -->';
if ( 1 === absint( $prtfl_options['shrdescription_additional_field'] ) && ( ! empty( $short_descr ) ) ) {
$content .= '<p>' . $short_descr . '</p>';
$content .= '</div> <!-- .portfolio_short_content -->
<a href="' . $permalink . '" rel="bookmark">' . __( 'Read more', 'portfolio' ) . '</a>
</div> <!-- .read_more -->
<div class="portfolio_terms">';
if ( 1 === absint( $prtfl_options['technologies_additional_field'] ) ) {
$terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' );
if ( is_array( $terms ) && 0 < count( $terms ) ) {
$content .= '<b>' . __( 'Technologies', 'portfolio' ) . ':</b> ';
foreach ( $terms as $term ) {
$content .= '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( 'View all projects in %s' ), $term->name ) . '">' . $term->name . '</a>';
$content .= '</div><!-- .portfolio_terms -->';
$content .= '<div class="prtfl_clear"></div></div> <!-- .portfolio_content --></div><!-- .gllr_image_block -->';
if ( ( $count_portfolio_row_block % $custom_portfolio_row_count ) === ( $custom_portfolio_row_count - 1 ) ) {
$content .= '<div class="clear"></div>
</div><!-- .gllr_image_row -->';
$count_portfolio_row_block++;
$content .= '</div> <!-- .prtfl_portfolio_block --><div class="clear"></div>';
$wp_query = $old_wp_query;
if ( ! function_exists( 'prtfl_admin_head' ) ) {
* Register style and script files
function prtfl_admin_head() {
global $prtfl_plugin_info, $hook_suffix, $post_type, $prtfl_options;
if ( ! $prtfl_plugin_info ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$prtfl_plugin_info = get_plugin_data( __FILE__ );
wp_enqueue_style( 'prtfl_icon', plugins_url( 'css/icon.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] );
if ( ( ( 'post.php' === $hook_suffix || 'post-new.php' === $hook_suffix ) && isset( $post_type ) && $prtfl_options['post_type_name'] === $post_type ) ||
( isset( $_GET['page'] ) && 'portfolio.php' === $_GET['page'] ) ) {
wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] );
wp_enqueue_style( 'prtfl_jquery-style', plugins_url( 'css/jquery-ui.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'prtfl_script', plugins_url( 'js/script.js', __FILE__ ), array(), $prtfl_plugin_info['Version'], true );
'prtfl_nonce' => wp_create_nonce( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ),
'update_img_message' => __( 'Updating images...', 'portfolio' ) . '<img class="prtfl_loader" src="' . plugins_url( 'images/ajax-loader.gif', __FILE__ ) . '" alt="" />',
'not_found_img_info' => __( 'No image found.', 'portfolio' ),
'img_success' => __( 'All images are updated.', 'portfolio' ),
bws_enqueue_settings_scripts();
bws_plugins_include_codemirror();
if ( ! function_exists( 'prtfl_wp_enqueue_scripts' ) ) {
* Enqueue fancybox script and style css
function prtfl_wp_enqueue_scripts() {
global $prtfl_plugin_info;
if ( ! $prtfl_plugin_info ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$prtfl_plugin_info = get_plugin_data( __FILE__ );
wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] );
wp_enqueue_style( 'prtfl_lightbox_stylesheet', plugins_url( 'fancybox/jquery.fancybox.min.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] );
if ( ! function_exists( 'prtfl_wp_head' ) ) {
function prtfl_wp_head() {
/* Add style for IE compatibility */
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Trident/7.0; rv:11.0' ) !== false || strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'MSIE' ) !== false ) {
$post_type = get_post_type();
if ( is_single() && $prtfl_options['post_type_name'] === $post_type ) {
.portfolio_images_gallery {
if ( ! function_exists( 'prtfl_wp_footer' ) ) {
* Initializing script of fancybox
function prtfl_wp_footer() {
global $prtfl_options, $post, $wp_query, $prtfl_plugin_info;
if ( ! $prtfl_plugin_info ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$prtfl_plugin_info = get_plugin_data( __FILE__ );
if ( ! empty( $wp_query->post->ID ) ) {
$post_thumbnail_id = get_post_thumbnail_id( $wp_query->post->ID );
$image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] );
if ( wp_script_is( 'prtfl_front_script', 'registered' ) ) {
wp_enqueue_script( 'prtfl_front_script' );
wp_enqueue_script( 'prtfl_fancyboxJs', plugins_url( 'fancybox/jquery.fancybox.min.js', __FILE__ ), array( 'jquery' ), $prtfl_plugin_info['Version'] );
/* Initialization of fancybox script */
if ( ! empty( $image[0] ) ) {
$script = "( function( $ ){
$( document ).ready( function(){
$( \"a[data-fancybox=portfolio_fancybox]\" ).fancybox({
animationEffect : 'zoom',
wp_register_script( 'prtfl_fancybox_script', '', array(), $prtfl_plugin_info['Version'] );
wp_enqueue_script( 'prtfl_fancybox_script' );
wp_add_inline_script( 'prtfl_fancybox_script', sprintf( $script ) );
if ( ! function_exists( 'prtfl_update_image' ) ) {
* Ajax function for updating images
function prtfl_update_image() {
global $wpdb, $prtfl_options;
check_ajax_referer( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' );
$action = isset( $_REQUEST['action1'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action1'] ) ) : '';
$id = isset( $_REQUEST['id'] ) ? absint( $_REQUEST['id'] ) : '';
case 'get_all_attachment':
$array_parent_id = $wpdb->get_col(
FROM ' . $wpdb->posts . '
$prtfl_options['post_type_name']
if ( ! empty( $array_parent_id ) ) {
$parent_id_placeholders = implode( ', ', array_fill( 0, count( (array) $array_parent_id ), '%d' ) );
$metas = $wpdb->get_results(
FROM ' . $wpdb->postmeta . '
AND post_id IN (' . $parent_id_placeholders . ')',
$result_attachment_id = '';
foreach ( $metas as $key => $value ) {
if ( ! empty( $value['meta_value'] ) ) {
$result_attachment_id .= $value['meta_value'] . ',';
$result_attachment_id_array = explode( ',', rtrim( $result_attachment_id, ',' ) );
$attached_id = $wpdb->get_results(
FROM ' . $wpdb->posts . '
AND post_mime_type LIKE %s
AND post_parent IN (' . $parent_id_placeholders . ')',
foreach ( $attached_id as $key => $value ) {
$result_attachment_id_array[] = $value['ID'];
echo wp_json_encode( array_unique( $result_attachment_id_array ) );
$metadata = wp_get_attachment_metadata( $id );