: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Displays the content on the plugin settings page
if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'Prtfl_Settings_Tabs' ) ) {
* Class for display Settings Tabs
class Prtfl_Settings_Tabs extends Bws_Settings_Tabs {
public $wp_image_sizes = array();
* Options for Custom Search plugin
public $cstmsrch_options;
* @see Bws_Settings_Tabs::__construct() for more information on default arguments.
* @param string $plugin_basename Plugin basename.
public function __construct( $plugin_basename ) {
global $prtfl_options, $prtfl_plugin_info, $prtfl_bws_demo_data;
'settings' => array( 'label' => __( 'Settings', 'portfolio' ) ),
'project' => array( 'label' => __( 'Project', 'portfolio' ) ),
'misc' => array( 'label' => __( 'Misc', 'portfolio' ) ),
'custom_code' => array( 'label' => __( 'Custom Code', 'portfolio' ) ),
'import-export' => array( 'label' => __( 'Import / Export', 'portfolio' ) ),
'license' => array( 'label' => __( 'License Key', 'portfolio' ) ),
'plugin_basename' => $plugin_basename,
'plugins_info' => $prtfl_plugin_info,
'default_options' => prtfl_get_options_default(),
'options' => $prtfl_options,
'wp_slug' => 'portfolio',
'demo_data' => $prtfl_bws_demo_data,
'link_key' => 'f047e20c92c972c398187a4f70240285',
'doc_link' => 'https://bestwebsoft.com/documentation/portfolio/portfolio-user-guide/',
$this->all_plugins = get_plugins();
$wp_sizes = get_intermediate_image_sizes();
foreach ( (array) $wp_sizes as $size ) {
if ( ! array_key_exists( $size, $prtfl_options['custom_size_px'] ) ) {
if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
$width = absint( $_wp_additional_image_sizes[ $size ]['width'] );
$height = absint( $_wp_additional_image_sizes[ $size ]['height'] );
$width = absint( get_option( $size . '_size_w' ) );
$height = absint( get_option( $size . '_size_h' ) );
if ( ! $width && ! $height ) {
$this->wp_image_sizes[] = array(
'name' => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ),
$this->wp_image_sizes[] = array(
'name' => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ) . ' (' . $width . ' × ' . $height . ')',
$this->cstmsrch_options = get_option( 'cstmsrch_options' );
'executor' => __( 'Executors', 'portfolio' ),
'technologies' => __( 'Technologies', 'portfolio' ),
'date' => __( 'Date of completion', 'portfolio' ),
'link' => __( 'Link', 'portfolio' ),
'shrdescription' => __( 'Short Description', 'portfolio' ),
'description' => __( 'Description', 'portfolio' ),
add_action( get_parent_class( $this ) . '_display_custom_messages', array( $this, 'display_custom_messages' ) );
add_action( get_parent_class( $this ) . '_additional_misc_options_affected', array( $this, 'additional_misc_options_affected' ) );
add_action( get_parent_class( $this ) . '_additional_import_export_options', array( $this, 'additional_import_export_options' ) );
add_action( get_parent_class( $this ) . '_display_metabox', array( $this, 'display_metabox' ) );
* Save plugin options to the database
* @return array The action results
public function save_options() {
if ( isset( $_POST['prtfl_settings_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['prtfl_settings_nonce'] ) ), 'prtfl_settings' ) ) {
$this->options['custom_image_row_count'] = isset( $_POST['prtfl_custom_image_row_count'] ) ? absint( $_POST['prtfl_custom_image_row_count'] ) : 3;
$this->options['custom_portfolio_row_count'] = isset( $_POST['prtfl_portfolio_custom_row_count'] ) ? absint( $_POST['prtfl_portfolio_custom_row_count'] ) : 1;
$new_image_size_photo = isset( $_POST['prtfl_image_size_photo'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_image_size_photo'] ) ) : 'thumbnail';
$custom_image_size_w_photo = isset( $_POST['prtfl_custom_image_size_w_photo'] ) ? absint( $_POST['prtfl_custom_image_size_w_photo'] ) : 240;
$custom_image_size_h_photo = isset( $_POST['prtfl_custom_image_size_h_photo'] ) ? absint( $_POST['prtfl_custom_image_size_h_photo'] ) : 260;
$custom_size_px_photo = array( $custom_image_size_w_photo, $custom_image_size_h_photo );
if ( 'portfolio-photo-thumb' === $new_image_size_photo ) {
if ( $new_image_size_photo !== $this->options['image_size_photo'] ) {
$need_image_update = true;
foreach ( $custom_size_px_photo as $key => $value ) {
if ( absint( $value ) !== absint( $this->options['custom_size_px']['portfolio-photo-thumb'][ $key ] ) ) {
$need_image_update = true;
$this->options['custom_size_px']['portfolio-photo-thumb'] = $custom_size_px_photo;
$this->options['image_size_photo'] = $new_image_size_photo;
$new_image_size_album = isset( $_POST['prtfl_image_size_album'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_image_size_album'] ) ) : 'medium';
$custom_image_size_w_album = isset( $_POST['prtfl_custom_image_size_w_album'] ) ? absint( $_POST['prtfl_custom_image_size_w_album'] ) : 280;
$custom_image_size_h_album = isset( $_POST['prtfl_custom_image_size_h_album'] ) ? absint( $_POST['prtfl_custom_image_size_h_album'] ) : 300;
$custom_size_px_album = array( $custom_image_size_w_album, $custom_image_size_h_album );
if ( 'portfolio-thumb' === $new_image_size_album ) {
if ( $new_image_size_album !== $this->options['image_size_album'] ) {
$need_image_update = true;
foreach ( $custom_size_px_album as $key => $value ) {
if ( absint( $value ) !== absint( $this->options['custom_size_px']['portfolio-thumb'][ $key ] ) ) {
$need_image_update = true;
$this->options['custom_size_px']['portfolio-thumb'] = $custom_size_px_album;
$this->options['image_size_album'] = $new_image_size_album;
if ( ! empty( $_POST['prtfl_page_id_portfolio_template'] ) && absint( $this->options['page_id_portfolio_template'] ) !== absint( $_POST['prtfl_page_id_portfolio_template'] ) ) {
$this->options['flush_rewrite_rules'] = 1;
$this->options['page_id_portfolio_template'] = absint( $_POST['prtfl_page_id_portfolio_template'] );
$this->options['order_by'] = isset( $_POST['prtfl_order_by'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_order_by'] ) ) : 'date';
$this->options['order'] = isset( $_POST['prtfl_order'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_order'] ) ) : 'DESC';
if ( ! empty( $need_image_update ) ) {
$this->options['need_image_update'] = __( 'Custom image size was changed. You need to update project images.', 'portfolio' );
$this->options['link_additional_field_for_non_registered'] = isset( $_POST['prtfl_link_additional_field_for_non_registered'] ) ? 1 : 0;
$this->options['svn_text_field'] = isset( $_POST['prtfl_svn_text_field'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_svn_text_field'] ) ) : '';
$this->options['svn_additional_field_for_non_logged'] = isset( $_POST['prtfl_svn_additional_field_for_non_logged'] ) ? 1 : 0;
$this->options['svn_additional_field'] = isset( $_POST['prtfl_svn_additional_field'] ) ? 1 : 0;
foreach ( $this->fields as $field_key => $field_title ) {
$this->options[ $field_key . '_additional_field' ] = isset( $_POST[ 'prtfl_' . $field_key . '_additional_field' ] ) ? 1 : 0;
$this->options[ $field_key . '_text_field' ] = isset( $_POST[ 'prtfl_' . $field_key . '_text_field' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'prtfl_' . $field_key . '_text_field' ] ) ) : '';
$this->options['screenshot_text_field'] = isset( $_POST['prtfl_screenshot_text_field'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_screenshot_text_field'] ) ) : '';
if ( isset( $_POST['prtfl_slug'] ) && sanitize_text_field( wp_unslash( $_POST['prtfl_slug'] ) ) !== $this->options['slug'] ) {
$this->options['flush_rewrite_rules'] = 1;
$this->options['slug'] = sanitize_text_field( wp_unslash( $_POST['prtfl_slug'] ) );
if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) {
$sndr_options = get_option( 'sndr_options' );
/* mailout when publishing quote */
if ( ! empty( $_POST['sndr_distribution_select'] ) && ! empty( $_POST['sndr_templates_select'] ) && ! empty( $_POST['sndr_priority'] ) ) {
if ( isset( $_POST['prtfl_sndr_mailout'] ) ) {
$key = array_search( 'bws-portfolio', $sndr_options['automailout_new_post'] );
$sndr_options['automailout_new_post'][] = 'bws-portfolio';
$sndr_options['group_for_post']['bws-portfolio'] = isset( $_POST['sndr_distribution_select']['bws-portfolio'] ) ? absint( $_POST['sndr_distribution_select']['bws-portfolio'] ) : 0;
$sndr_options['letter_for_post']['bws-portfolio'] = isset( $_POST['sndr_templates_select']['bws-portfolio'] ) ? absint( $_POST['sndr_templates_select']['bws-portfolio'] ) : 0;
$sndr_options['priority_for_post_letters']['bws-portfolio'] = isset( $_POST['sndr_priority']['bws-portfolio'] ) ? absint( $_POST['sndr_priority']['bws-portfolio'] ) : 0;
$key = array_search( 'bws-portfolio', $sndr_options['automailout_new_post'] );
unset( $sndr_options['automailout_new_post'][ $key ] );
unset( $sndr_options['priority_for_post_letters']['bws-portfolio'] );
unset( $sndr_options['letter_for_post']['bws-portfolio'] );
unset( $sndr_options['group_for_post']['bws-portfolio'] );
update_option( 'sndr_options', $sndr_options );
* Rewriting post types name with unique one from default options
if ( ! empty( $_POST['prtfl_rename_post_type'] ) ) {
array( 'post_type' => $this->default_options['post_type_name'] ),
array( 'post_type' => $this->options['post_type_name'] )
$this->options['post_type_name'] = $this->default_options['post_type_name'];
if ( ! empty( $this->cstmsrch_options ) ) {
if ( isset( $this->cstmsrch_options['output_order'] ) ) {
$is_enabled = isset( $_POST['prtfl_add_to_search'] ) ? 1 : 0;
$post_type_exist = false;
foreach ( $this->cstmsrch_options['output_order'] as $key => $item ) {
if ( $item['name'] === $this->options['post_type_name'] && 'post_type' === $item['type'] ) {
if ( absint( $item['enabled'] ) !== absint( $is_enabled ) ) {
$this->cstmsrch_options['output_order'][ $key ]['enabled'] = $is_enabled;
$cstmsrch_options_update = true;
if ( ! $post_type_exist ) {
$this->cstmsrch_options['output_order'][] = array(
'name' => $this->options['post_type_name'],
'enabled' => $is_enabled,
$cstmsrch_options_update = true;
} elseif ( isset( $this->cstmsrch_options['post_types'] ) ) {
if ( isset( $_POST['prtfl_add_to_search'] ) && ! in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
array_push( $this->cstmsrch_options['post_types'], $this->options['post_type_name'] );
$cstmsrch_options_update = true;
} elseif ( ! isset( $_POST['prtfl_add_to_search'] ) && in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
unset( $this->cstmsrch_options['post_types'][ array_search( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ] );
$cstmsrch_options_update = true;
if ( isset( $cstmsrch_options_update ) ) {
update_option( 'cstmsrch_options', $this->cstmsrch_options );
update_option( 'prtfl_options', $this->options );
$message = __( 'Settings saved.', 'portfolio' );
return compact( 'message', 'notice', 'error' );
* Display custom error\message\notice
* @param array $save_results Array with error\message\notice.
public function display_custom_messages( $save_results ) { ?>
<noscript><div class="error below-h2"><p><strong><?php esc_html_e( 'Please enable JavaScript in Your browser.', 'portfolio' ); ?></strong></p></div></noscript>
<?php if ( ! empty( $this->options['need_image_update'] ) ) { ?>
<div class="updated bws-notice inline prtfl_image_update_message">
<?php echo esc_html( $this->options['need_image_update'] ); ?>
<input type="button" value="<?php esc_html_e( 'Update Images', 'portfolio' ); ?>" id="prtfl_ajax_update_images" name="ajax_update_images" class="button" />
public function tab_settings() {
if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) {
$sndr_options = get_option( 'sndr_options' );
<h3 class="bws_tab_label"><?php esc_html_e( 'Portfolio Settings', 'portfolio' ); ?></h3>
<?php $this->help_phrase(); ?>
<table class="form-table">
<th scope="row"><?php esc_html_e( 'Portfolio Page', 'portfolio' ); ?></th>
'selected' => esc_attr( $this->options['page_id_portfolio_template'] ),
'name' => 'prtfl_page_id_portfolio_template',
'show_option_none' => '...',
<div class="bws_info"><?php esc_html_e( 'Base page where all existing projects will be displayed.', 'portfolio' ); ?></div>
<th scope="row"><?php esc_html_e( 'Number of Columns', 'portfolio' ); ?> </th>
<input<?php echo esc_html( $this->change_permission_attr ); ?> type="number" name="prtfl_portfolio_custom_row_count" min="1" max="10000" value="<?php echo esc_attr( $this->options['custom_portfolio_row_count'] ); ?>" /> <?php esc_html_e( 'columns', 'portfolio' ); ?>
<div class="bws_info"><?php printf( esc_html__( 'Number of portfolio columns (default is %s).', 'portfolio' ), '1' ); ?></div>
<th scope="row"><?php esc_html_e( 'Number of Image Columns', 'portfolio' ); ?> </th>
<input type="number" name="prtfl_custom_image_row_count" min="1" max="10000" value="<?php echo esc_attr( $this->options['custom_image_row_count'] ); ?>" /> <?php esc_html_e( 'columns', 'portfolio' ); ?>
<div class="bws_info"><?php printf( esc_html__( 'Number of image columns (default is %s).', 'portfolio' ), '3' ); ?></div>
<th scope="row"><?php esc_html_e( 'Image Size', 'portfolio' ); ?></th>
<select name="prtfl_image_size_photo">
<?php foreach ( $this->wp_image_sizes as $data ) { ?>
<option value="<?php echo esc_attr( $data['value'] ); ?>" <?php selected( $data['value'], $this->options['image_size_photo'] ); ?>><?php echo esc_html( $data['name'] ); ?></option>
<option value="portfolio-photo-thumb" <?php selected( 'portfolio-photo-thumb', $this->options['image_size_photo'] ); ?> class="bws_option_affect" data-affect-show=".prtfl_for_custom_image_size"><?php esc_html_e( 'Custom', 'portfolio' ); ?></option>
<div class="bws_info"><?php esc_html_e( 'Maximum portfolio image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
<tr valign="top" class="prtfl_for_custom_image_size">
<th scope="row"><?php esc_html_e( 'Custom Image Size', 'portfolio' ); ?> </th>
<input type="number" name="prtfl_custom_image_size_w_photo" min="1" max="10000" value="<?php echo esc_attr( $this->options['custom_size_px']['portfolio-photo-thumb'][0] ); ?>" /> x <input type="number" name="prtfl_custom_image_size_h_photo" min="1" max="10000" value="<?php echo esc_attr( $this->options['custom_size_px']['portfolio-photo-thumb'][1] ); ?>" /> px <div class="bws_info"><?php esc_html_e( "Adjust these values based on the number of columns in your project. This won't affect the full size of your images in the lightbox.", 'portfolio' ); ?></div>
<th scope="row"><?php esc_html_e( 'Cover Image Size', 'portfolio' ); ?> </th>
<select name="prtfl_image_size_album">
<?php foreach ( $this->wp_image_sizes as $data ) { ?>
<option value="<?php echo esc_attr( $data['value'] ); ?>" <?php selected( $data['value'], $this->options['image_size_album'] ); ?>><?php echo esc_html( $data['name'] ); ?></option>
<option value="portfolio-thumb" <?php selected( 'portfolio-thumb', $this->options['image_size_album'] ); ?> class="bws_option_affect" data-affect-show=".prtfl_for_custom_image_size_album"><?php esc_html_e( 'Custom', 'portfolio' ); ?></option>
<div class="bws_info"><?php esc_html_e( 'Maximum cover image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
<tr valign="top" class="prtfl_for_custom_image_size_album">
<th scope="row"><?php esc_html_e( 'Custom Cover Image Size', 'portfolio' ); ?> </th>
<input type="number" name="prtfl_custom_image_size_w_album" min="1" max="10000" value="<?php echo esc_attr( $this->options['custom_size_px']['portfolio-thumb'][0] ); ?>" /> x <input type="number" name="prtfl_custom_image_size_h_album" min="1" max="10000" value="<?php echo esc_attr( $this->options['custom_size_px']['portfolio-thumb'][1] ); ?>" /> px
<?php if ( ! $this->hide_pro_tabs ) { ?>
<div class="bws_pro_version_bloc">
<div class="bws_pro_version_table_bloc">
<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php esc_html_e( 'Close', 'portfolio' ); ?>"></button>
<div class="bws_table_bg"></div>
<table class="form-table bws_pro_version">
<th scope="row"><?php esc_html_e( 'Slider Image Size', 'portfolio' ); ?> </th>
<select disabled="disabled" name="prtfl_image_size_slider">
<option value="large">Large (1024 × 1024)</option>
<div class="bws_info"><?php esc_html_e( 'Maximum slider image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
<th scope="row"><?php esc_html_e( 'Sort Projects Option', 'portfolio' ); ?></th>
<input type="checkbox" name="prtfl_sorting_selectbox" value="1" disabled="disabled" /> <span class="bws_info"><?php esc_html_e( 'Enable to display sort projects manually by date or title.', 'portfolio' ); ?></span>
<?php $this->bws_pro_block_links(); ?>
<table class="form-table">
<th scope="row"><?php esc_html_e( 'Sort Projects by', 'portfolio' ); ?></th>
<select name="prtfl_order_by">
<option value="ID" <?php selected( 'ID', $this->options['order_by'] ); ?>><?php esc_html_e( 'Project ID', 'portfolio' ); ?></option>
<option value="title" <?php selected( 'title', $this->options['order_by'] ); ?>><?php esc_html_e( 'Title', 'portfolio' ); ?></option>
<option value="date" <?php selected( 'date', $this->options['order_by'] ); ?>><?php esc_html_e( 'Date', 'portfolio' ); ?></option>
<option value="modified" <?php selected( 'modified', $this->options['order_by'] ); ?>><?php esc_html_e( 'Last modified date', 'portfolio' ); ?></option>
<option value="comment_count" <?php selected( 'comment_count', $this->options['order_by'] ); ?>><?php esc_html_e( 'Comment count', 'portfolio' ); ?></option>
<option value="menu_order" <?php selected( 'menu_order', $this->options['order_by'] ); ?>><?php esc_html_e( 'Sorting order (the input field for sorting order)', 'portfolio' ); ?></option>
<option value="author" <?php selected( 'author', $this->options['order_by'] ); ?>><?php esc_html_e( 'Author', 'portfolio' ); ?></option>
<option value="rand" <?php selected( 'rand', $this->options['order_by'] ); ?>><?php esc_html_e( 'Random', 'portfolio' ); ?></option>
<div class="bws_info"><?php esc_html_e( 'Select projects sorting order in your portfolio page.', 'portfolio' ); ?></div>
<th scope="row"><?php esc_html_e( 'Arrange Projects by', 'portfolio' ); ?></th>
<label><input type="radio" name="prtfl_order" value="ASC" <?php checked( 'ASC', $this->options['order'] ); ?> /> <?php esc_html_e( 'Ascending (e.g. 1, 2, 3; a, b, c)', 'portfolio' ); ?></label>
<label><input type="radio" name="prtfl_order" value="DESC" <?php checked( 'DESC', $this->options['order'] ); ?> /> <?php esc_html_e( 'Descending (e.g. 3, 2, 1; c, b, a)', 'portfolio' ); ?></label>
<?php if ( ! $this->hide_pro_tabs ) { ?>
<div class="bws_pro_version_bloc">
<div class="bws_pro_version_table_bloc">
<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php esc_html_e( 'Close', 'portfolio' ); ?>"></button>
<div class="bws_table_bg"></div>
<table class="form-table bws_pro_version">
<th scope="row"><?php esc_html_e( 'Lightbox Helper', 'portfolio' ); ?></th>
<input disabled type="checkbox" name="" /> <span class="bws_info"><?php esc_html_e( 'Enable to use a lightbox helper navigation between images.', 'portfolio' ); ?></span>
<th scope="row"><?php esc_html_e( 'Lightbox Helper Type', 'portfolio' ); ?></th>
<select disabled name="">
<option><?php esc_html_e( 'Thumbnails', 'portfolio' ); ?></option>
<option><?php esc_html_e( 'Buttons', 'portfolio' ); ?></option>
<?php $this->bws_pro_block_links(); ?>
<table class="form-table">
<th scope="row"><?php esc_html_e( 'Text Link', 'portfolio' ); ?></th>
<input type="checkbox" name="prtfl_link_additional_field_for_non_registered" value="1" id="prtfl_link_additional_field_for_non_registered" <?php checked( 1, $this->options['link_additional_field_for_non_registered'] ); ?> /> <span class="bws_info"><?php esc_html_e( 'Enable to display link field as a text for non-registered users.', 'portfolio' ); ?></span>
<th scope="row"><?php esc_html_e( 'Automatic Mailout when Publishing a New:', 'portfolio' ); ?></th>
if ( array_key_exists( 'sender-pro/sender-pro.php', $this->all_plugins ) ) {
if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) {
<input type="checkbox" name="prtfl_sndr_mailout" value="1" class="bws_option_affect" data-affect-show="[data-post-type=bws-portfolio]" <?php checked( in_array( 'bws-portfolio', $sndr_options['automailout_new_post'] ) ); ?> /> <?php esc_html_e( 'Projects', 'portfolio' ); ?>
<div data-post-type="bws-portfolio">
<p><?php sndr_distribution_list_select( $sndr_options['group_for_post'], 'bws-portfolio' ); ?></p>
<p><?php sndr_letters_list_select( $sndr_options['letter_for_post'], 'bws-portfolio' ); ?></p>
sndr_priorities_list( $sndr_options['priority_for_post_letters'], '', 'bws-portfolio' );
esc_html_e( 'Select mailout priority', 'portfolio' );
<br /><span class="bws_info"><?php esc_html_e( 'Less number - higher priority', 'portfolio' ); ?></span>