wp/wp-content/plugins/portfolio/includes/class-prtfl-settings.php
changeset 21 48c4eec2b7e6
child 23 417f20492bf7
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
       
     1 <?php
       
     2 /**
       
     3  * Displays the content on the plugin settings page
       
     4  */
       
     5 
       
     6 if ( ! defined( 'ABSPATH' ) ) {
       
     7 	die();
       
     8 }
       
     9 
       
    10 if ( ! class_exists( 'Prtfl_Settings_Tabs' ) ) {
       
    11 	/**
       
    12 	 * Class for display Settings Tabs
       
    13 	 */
       
    14 	class Prtfl_Settings_Tabs extends Bws_Settings_Tabs {
       
    15 
       
    16 		/**
       
    17 		 * Image sizes array
       
    18 		 *
       
    19 		 * @var array
       
    20 		 */
       
    21 		public $wp_image_sizes = array();
       
    22 
       
    23 		/**
       
    24 		 * Options for Custom Search plugin
       
    25 		 *
       
    26 		 * @var array
       
    27 		 */
       
    28 		public $cstmsrch_options;
       
    29 
       
    30 		/**
       
    31 		 * Fields for portfolio
       
    32 		 *
       
    33 		 * @var array
       
    34 		 */
       
    35 		public $fields;
       
    36 
       
    37 		/**
       
    38 		 * Constructor.
       
    39 		 *
       
    40 		 * @access public
       
    41 		 *
       
    42 		 * @see Bws_Settings_Tabs::__construct() for more information on default arguments.
       
    43 		 *
       
    44 		 * @param string $plugin_basename Plugin basename.
       
    45 		 */
       
    46 		public function __construct( $plugin_basename ) {
       
    47 			global $prtfl_options, $prtfl_plugin_info, $prtfl_bws_demo_data;
       
    48 
       
    49 			$tabs = array(
       
    50 				'settings'      => array( 'label' => __( 'Settings', 'portfolio' ) ),
       
    51 				'project'       => array( 'label' => __( 'Project', 'portfolio' ) ),
       
    52 				'misc'          => array( 'label' => __( 'Misc', 'portfolio' ) ),
       
    53 				'custom_code'   => array( 'label' => __( 'Custom Code', 'portfolio' ) ),
       
    54 				'import-export' => array( 'label' => __( 'Import / Export', 'portfolio' ) ),
       
    55 				'license'       => array( 'label' => __( 'License Key', 'portfolio' ) ),
       
    56 			);
       
    57 
       
    58 			parent::__construct(
       
    59 				array(
       
    60 					'plugin_basename' => $plugin_basename,
       
    61 					'plugins_info'    => $prtfl_plugin_info,
       
    62 					'prefix'          => 'prtfl',
       
    63 					'default_options' => prtfl_get_options_default(),
       
    64 					'options'         => $prtfl_options,
       
    65 					'tabs'            => $tabs,
       
    66 					'wp_slug'         => 'portfolio',
       
    67 					'demo_data'       => $prtfl_bws_demo_data,
       
    68 					'link_key'        => 'f047e20c92c972c398187a4f70240285',
       
    69 					'link_pn'         => '74',
       
    70 					'doc_link'        => 'https://bestwebsoft.com/documentation/portfolio/portfolio-user-guide/',
       
    71 				)
       
    72 			);
       
    73 
       
    74 			$this->all_plugins = get_plugins();
       
    75 
       
    76 			$wp_sizes = get_intermediate_image_sizes();
       
    77 
       
    78 			foreach ( (array) $wp_sizes as $size ) {
       
    79 				if ( ! array_key_exists( $size, $prtfl_options['custom_size_px'] ) ) {
       
    80 					if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
       
    81 						$width  = absint( $_wp_additional_image_sizes[ $size ]['width'] );
       
    82 						$height = absint( $_wp_additional_image_sizes[ $size ]['height'] );
       
    83 					} else {
       
    84 						$width  = absint( get_option( $size . '_size_w' ) );
       
    85 						$height = absint( get_option( $size . '_size_h' ) );
       
    86 					}
       
    87 
       
    88 					if ( ! $width && ! $height ) {
       
    89 						$this->wp_image_sizes[] = array(
       
    90 							'value' => $size,
       
    91 							'name'  => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ),
       
    92 						);
       
    93 					} else {
       
    94 						$this->wp_image_sizes[] = array(
       
    95 							'value'  => $size,
       
    96 							'name'   => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ) . ' (' . $width . ' &#215; ' . $height . ')',
       
    97 							'width'  => $width,
       
    98 							'height' => $height,
       
    99 						);
       
   100 					}
       
   101 				}
       
   102 			}
       
   103 
       
   104 			$this->cstmsrch_options = get_option( 'cstmsrch_options' );
       
   105 
       
   106 			$this->fields = array(
       
   107 				'executor'       => __( 'Executors', 'portfolio' ),
       
   108 				'technologies'   => __( 'Technologies', 'portfolio' ),
       
   109 				'date'           => __( 'Date of completion', 'portfolio' ),
       
   110 				'link'           => __( 'Link', 'portfolio' ),
       
   111 				'shrdescription' => __( 'Short Description', 'portfolio' ),
       
   112 				'description'    => __( 'Description', 'portfolio' ),
       
   113 
       
   114 			);
       
   115 
       
   116 			add_action( get_parent_class( $this ) . '_display_custom_messages', array( $this, 'display_custom_messages' ) );
       
   117 			add_action( get_parent_class( $this ) . '_additional_misc_options_affected', array( $this, 'additional_misc_options_affected' ) );
       
   118 			add_action( get_parent_class( $this ) . '_additional_import_export_options', array( $this, 'additional_import_export_options' ) );
       
   119 			add_action( get_parent_class( $this ) . '_display_metabox', array( $this, 'display_metabox' ) );
       
   120 		}
       
   121 
       
   122 		/**
       
   123 		 * Save plugin options to the database
       
   124 		 *
       
   125 		 * @access public
       
   126 		 * @return array The action results
       
   127 		 */
       
   128 		public function save_options() {
       
   129 
       
   130 			$message = '';
       
   131 			$notice  = '';
       
   132 			$error   = '';
       
   133 
       
   134 			if ( isset( $_POST['prtfl_settings_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['prtfl_settings_nonce'] ) ), 'prtfl_settings' ) ) {
       
   135 
       
   136 				$this->options['custom_image_row_count']     = isset( $_POST['prtfl_custom_image_row_count'] ) ? absint( $_POST['prtfl_custom_image_row_count'] ) : 3;
       
   137 				$this->options['custom_portfolio_row_count'] = isset( $_POST['prtfl_portfolio_custom_row_count'] ) ? absint( $_POST['prtfl_portfolio_custom_row_count'] ) : 1;
       
   138 
       
   139 				$new_image_size_photo      = isset( $_POST['prtfl_image_size_photo'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_image_size_photo'] ) ) : 'thumbnail';
       
   140 				$custom_image_size_w_photo = isset( $_POST['prtfl_custom_image_size_w_photo'] ) ? absint( $_POST['prtfl_custom_image_size_w_photo'] ) : 240;
       
   141 				$custom_image_size_h_photo = isset( $_POST['prtfl_custom_image_size_h_photo'] ) ? absint( $_POST['prtfl_custom_image_size_h_photo'] ) : 260;
       
   142 				$custom_size_px_photo      = array( $custom_image_size_w_photo, $custom_image_size_h_photo );
       
   143 				if ( 'portfolio-photo-thumb' === $new_image_size_photo ) {
       
   144 					if ( $new_image_size_photo !== $this->options['image_size_photo'] ) {
       
   145 						$need_image_update = true;
       
   146 					} else {
       
   147 						foreach ( $custom_size_px_photo as $key => $value ) {
       
   148 							if ( absint( $value ) !== absint( $this->options['custom_size_px']['portfolio-photo-thumb'][ $key ] ) ) {
       
   149 								$need_image_update = true;
       
   150 								break;
       
   151 							}
       
   152 						}
       
   153 					}
       
   154 				}
       
   155 				$this->options['custom_size_px']['portfolio-photo-thumb'] = $custom_size_px_photo;
       
   156 				$this->options['image_size_photo']                        = $new_image_size_photo;
       
   157 
       
   158 				$new_image_size_album      = isset( $_POST['prtfl_image_size_album'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_image_size_album'] ) ) : 'medium';
       
   159 				$custom_image_size_w_album = isset( $_POST['prtfl_custom_image_size_w_album'] ) ? absint( $_POST['prtfl_custom_image_size_w_album'] ) : 280;
       
   160 				$custom_image_size_h_album = isset( $_POST['prtfl_custom_image_size_h_album'] ) ? absint( $_POST['prtfl_custom_image_size_h_album'] ) : 300;
       
   161 				$custom_size_px_album      = array( $custom_image_size_w_album, $custom_image_size_h_album );
       
   162 				if ( 'portfolio-thumb' === $new_image_size_album ) {
       
   163 					if ( $new_image_size_album !== $this->options['image_size_album'] ) {
       
   164 						$need_image_update = true;
       
   165 					} else {
       
   166 						foreach ( $custom_size_px_album as $key => $value ) {
       
   167 							if ( absint( $value ) !== absint( $this->options['custom_size_px']['portfolio-thumb'][ $key ] ) ) {
       
   168 								$need_image_update = true;
       
   169 								break;
       
   170 							}
       
   171 						}
       
   172 					}
       
   173 				}
       
   174 
       
   175 				$this->options['custom_size_px']['portfolio-thumb'] = $custom_size_px_album;
       
   176 				$this->options['image_size_album']                  = $new_image_size_album;
       
   177 
       
   178 				if ( ! empty( $_POST['prtfl_page_id_portfolio_template'] ) && absint( $this->options['page_id_portfolio_template'] ) !== absint( $_POST['prtfl_page_id_portfolio_template'] ) ) {
       
   179 					/* for rewrite */
       
   180 					$this->options['flush_rewrite_rules']        = 1;
       
   181 					$this->options['page_id_portfolio_template'] = absint( $_POST['prtfl_page_id_portfolio_template'] );
       
   182 				}
       
   183 
       
   184 				$this->options['order_by'] = isset( $_POST['prtfl_order_by'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_order_by'] ) ) : 'date';
       
   185 				$this->options['order']    = isset( $_POST['prtfl_order'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_order'] ) ) : 'DESC';
       
   186 
       
   187 				if ( ! empty( $need_image_update ) ) {
       
   188 					$this->options['need_image_update'] = __( 'Custom image size was changed. You need to update project images.', 'portfolio' );
       
   189 				}
       
   190 
       
   191 				$this->options['link_additional_field_for_non_registered'] = isset( $_POST['prtfl_link_additional_field_for_non_registered'] ) ? 1 : 0;
       
   192 				$this->options['svn_text_field']                           = isset( $_POST['prtfl_svn_text_field'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_svn_text_field'] ) ) : '';
       
   193 				$this->options['svn_additional_field_for_non_logged']      = isset( $_POST['prtfl_svn_additional_field_for_non_logged'] ) ? 1 : 0;
       
   194 				$this->options['svn_additional_field']                     = isset( $_POST['prtfl_svn_additional_field'] ) ? 1 : 0;
       
   195 
       
   196 				foreach ( $this->fields as $field_key => $field_title ) {
       
   197 					$this->options[ $field_key . '_additional_field' ] = isset( $_POST[ 'prtfl_' . $field_key . '_additional_field' ] ) ? 1 : 0;
       
   198 					$this->options[ $field_key . '_text_field' ]       = isset( $_POST[ 'prtfl_' . $field_key . '_text_field' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'prtfl_' . $field_key . '_text_field' ] ) ) : '';
       
   199 
       
   200 				}
       
   201 
       
   202 				$this->options['screenshot_text_field'] = isset( $_POST['prtfl_screenshot_text_field'] ) ? sanitize_text_field( wp_unslash( $_POST['prtfl_screenshot_text_field'] ) ) : '';
       
   203 
       
   204 				if ( isset( $_POST['prtfl_slug'] ) && sanitize_text_field( wp_unslash( $_POST['prtfl_slug'] ) ) !== $this->options['slug'] ) {
       
   205 					$this->options['flush_rewrite_rules'] = 1;
       
   206 				}
       
   207 				$this->options['slug'] = sanitize_text_field( wp_unslash( $_POST['prtfl_slug'] ) );
       
   208 
       
   209 				if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) {
       
   210 					$sndr_options = get_option( 'sndr_options' );
       
   211 					/* mailout when publishing quote */
       
   212 					if ( ! empty( $_POST['sndr_distribution_select'] ) && ! empty( $_POST['sndr_templates_select'] ) && ! empty( $_POST['sndr_priority'] ) ) {
       
   213 						if ( isset( $_POST['prtfl_sndr_mailout'] ) ) {
       
   214 							$key = array_search( 'bws-portfolio', $sndr_options['automailout_new_post'] );
       
   215 							if ( false === $key ) {
       
   216 								$sndr_options['automailout_new_post'][]                     = 'bws-portfolio';
       
   217 								$sndr_options['group_for_post']['bws-portfolio']            = isset( $_POST['sndr_distribution_select']['bws-portfolio'] ) ? absint( $_POST['sndr_distribution_select']['bws-portfolio'] ) : 0;
       
   218 								$sndr_options['letter_for_post']['bws-portfolio']           = isset( $_POST['sndr_templates_select']['bws-portfolio'] ) ? absint( $_POST['sndr_templates_select']['bws-portfolio'] ) : 0;
       
   219 								$sndr_options['priority_for_post_letters']['bws-portfolio'] = isset( $_POST['sndr_priority']['bws-portfolio'] ) ? absint( $_POST['sndr_priority']['bws-portfolio'] ) : 0;
       
   220 							}
       
   221 						} else {
       
   222 							$key = array_search( 'bws-portfolio', $sndr_options['automailout_new_post'] );
       
   223 							if ( false !== $key ) {
       
   224 								unset( $sndr_options['automailout_new_post'][ $key ] );
       
   225 								unset( $sndr_options['priority_for_post_letters']['bws-portfolio'] );
       
   226 								unset( $sndr_options['letter_for_post']['bws-portfolio'] );
       
   227 								unset( $sndr_options['group_for_post']['bws-portfolio'] );
       
   228 							}
       
   229 						}
       
   230 					}
       
   231 					update_option( 'sndr_options', $sndr_options );
       
   232 				}
       
   233 
       
   234 				/**
       
   235 				 * Rewriting post types name with unique one from default options
       
   236 				 */
       
   237 				if ( ! empty( $_POST['prtfl_rename_post_type'] ) ) {
       
   238 					global $wpdb;
       
   239 					$wpdb->update(
       
   240 						$wpdb->prefix . 'posts',
       
   241 						array( 'post_type' => $this->default_options['post_type_name'] ),
       
   242 						array( 'post_type' => $this->options['post_type_name'] )
       
   243 					);
       
   244 					$this->options['post_type_name'] = $this->default_options['post_type_name'];
       
   245 				}
       
   246 
       
   247 				if ( ! empty( $this->cstmsrch_options ) ) {
       
   248 					if ( isset( $this->cstmsrch_options['output_order'] ) ) {
       
   249 						$is_enabled      = isset( $_POST['prtfl_add_to_search'] ) ? 1 : 0;
       
   250 						$post_type_exist = false;
       
   251 						foreach ( $this->cstmsrch_options['output_order'] as $key => $item ) {
       
   252 							if ( $item['name'] === $this->options['post_type_name'] && 'post_type' === $item['type'] ) {
       
   253 								$post_type_exist = true;
       
   254 								if ( absint( $item['enabled'] ) !== absint( $is_enabled ) ) {
       
   255 									$this->cstmsrch_options['output_order'][ $key ]['enabled'] = $is_enabled;
       
   256 									$cstmsrch_options_update                                   = true;
       
   257 								}
       
   258 								break;
       
   259 							}
       
   260 						}
       
   261 						if ( ! $post_type_exist ) {
       
   262 							$this->cstmsrch_options['output_order'][] = array(
       
   263 								'name'    => $this->options['post_type_name'],
       
   264 								'type'    => 'post_type',
       
   265 								'enabled' => $is_enabled,
       
   266 							);
       
   267 							$cstmsrch_options_update                  = true;
       
   268 						}
       
   269 					} elseif ( isset( $this->cstmsrch_options['post_types'] ) ) {
       
   270 						if ( isset( $_POST['prtfl_add_to_search'] ) && ! in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
       
   271 							array_push( $this->cstmsrch_options['post_types'], $this->options['post_type_name'] );
       
   272 							$cstmsrch_options_update = true;
       
   273 						} elseif ( ! isset( $_POST['prtfl_add_to_search'] ) && in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
       
   274 							unset( $this->cstmsrch_options['post_types'][ array_search( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ] );
       
   275 							$cstmsrch_options_update = true;
       
   276 						}
       
   277 					}
       
   278 					if ( isset( $cstmsrch_options_update ) ) {
       
   279 						update_option( 'cstmsrch_options', $this->cstmsrch_options );
       
   280 					}
       
   281 				}
       
   282 
       
   283 				update_option( 'prtfl_options', $this->options );
       
   284 				$message = __( 'Settings saved.', 'portfolio' );
       
   285 			}
       
   286 
       
   287 			return compact( 'message', 'notice', 'error' );
       
   288 		}
       
   289 
       
   290 		/**
       
   291 		 * Display custom error\message\notice
       
   292 		 *
       
   293 		 * @access public
       
   294 		 * @param array $save_results Array with error\message\notice.
       
   295 		 */
       
   296 		public function display_custom_messages( $save_results ) { ?>
       
   297 			<noscript><div class="error below-h2"><p><strong><?php esc_html_e( 'Please enable JavaScript in Your browser.', 'portfolio' ); ?></strong></p></div></noscript>
       
   298 			<?php if ( ! empty( $this->options['need_image_update'] ) ) { ?>
       
   299 				<div class="updated bws-notice inline prtfl_image_update_message">
       
   300 					<p>
       
   301 						<?php echo esc_html( $this->options['need_image_update'] ); ?>
       
   302 						<input type="button" value="<?php esc_html_e( 'Update Images', 'portfolio' ); ?>" id="prtfl_ajax_update_images" name="ajax_update_images" class="button" />
       
   303 					</p>
       
   304 				</div>
       
   305 				<?php
       
   306 			}
       
   307 		}
       
   308 
       
   309 		/**
       
   310 		 * Display 'Settings'
       
   311 		 */
       
   312 		public function tab_settings() {
       
   313 			if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) {
       
   314 				$sndr_options = get_option( 'sndr_options' );
       
   315 			}
       
   316 			?>
       
   317 			<h3 class="bws_tab_label"><?php esc_html_e( 'Portfolio Settings', 'portfolio' ); ?></h3>
       
   318 			<?php $this->help_phrase(); ?>
       
   319 			<hr>
       
   320 			<table class="form-table">
       
   321 				<tr valign="top">
       
   322 					<th scope="row"><?php esc_html_e( 'Portfolio Page', 'portfolio' ); ?></th>
       
   323 					<td>
       
   324 						<?php
       
   325 						wp_dropdown_pages(
       
   326 							array(
       
   327 								'depth'            => 0,
       
   328 								'selected'         => esc_attr( $this->options['page_id_portfolio_template'] ),
       
   329 								'name'             => 'prtfl_page_id_portfolio_template',
       
   330 								'show_option_none' => '...',
       
   331 							)
       
   332 						);
       
   333 						?>
       
   334 						<div class="bws_info"><?php esc_html_e( 'Base page where all existing projects will be displayed.', 'portfolio' ); ?></div>
       
   335 					</td>
       
   336 				</tr>
       
   337 				<tr valign="top">
       
   338 					<th scope="row"><?php esc_html_e( 'Number of Columns', 'portfolio' ); ?> </th>
       
   339 					<td>
       
   340 						<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' ); ?>
       
   341 						<div class="bws_info"><?php printf( esc_html__( 'Number of portfolio columns (default is %s).', 'portfolio' ), '1' ); ?></div>
       
   342 					</td>
       
   343 				</tr>
       
   344 				<tr valign="top">
       
   345 					<th scope="row"><?php esc_html_e( 'Number of Image Columns', 'portfolio' ); ?> </th>
       
   346 					<td>
       
   347 						<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' ); ?>
       
   348 						<div class="bws_info"><?php printf( esc_html__( 'Number of image columns (default is %s).', 'portfolio' ), '3' ); ?></div>
       
   349 					</td>
       
   350 				</tr>
       
   351 				<tr valign="top">
       
   352 					<th scope="row"><?php esc_html_e( 'Image Size', 'portfolio' ); ?></th>
       
   353 					<td>
       
   354 						<select name="prtfl_image_size_photo">
       
   355 							<?php foreach ( $this->wp_image_sizes as $data ) { ?>
       
   356 								<option value="<?php echo esc_attr( $data['value'] ); ?>" <?php selected( $data['value'], $this->options['image_size_photo'] ); ?>><?php echo esc_html( $data['name'] ); ?></option>
       
   357 							<?php } ?>
       
   358 							<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>
       
   359 						</select>
       
   360 						<div class="bws_info"><?php esc_html_e( 'Maximum portfolio image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
       
   361 					</td>
       
   362 				</tr>
       
   363 				<tr valign="top" class="prtfl_for_custom_image_size">
       
   364 					<th scope="row"><?php esc_html_e( 'Custom Image Size', 'portfolio' ); ?> </th>
       
   365 					<td>
       
   366 						<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>
       
   367 					</td>
       
   368 				</tr>
       
   369 				<tr valign="top">
       
   370 					<th scope="row"><?php esc_html_e( 'Cover Image Size', 'portfolio' ); ?> </th>
       
   371 					<td>
       
   372 						<select name="prtfl_image_size_album">
       
   373 							<?php foreach ( $this->wp_image_sizes as $data ) { ?>
       
   374 								<option value="<?php echo esc_attr( $data['value'] ); ?>" <?php selected( $data['value'], $this->options['image_size_album'] ); ?>><?php echo esc_html( $data['name'] ); ?></option>
       
   375 							<?php } ?>
       
   376 							<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>
       
   377 						</select>
       
   378 						<div class="bws_info"><?php esc_html_e( 'Maximum cover image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
       
   379 					</td>
       
   380 				</tr>
       
   381 				<tr valign="top" class="prtfl_for_custom_image_size_album">
       
   382 					<th scope="row"><?php esc_html_e( 'Custom Cover Image Size', 'portfolio' ); ?> </th>
       
   383 					<td>
       
   384 						<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
       
   385 					</td>
       
   386 				</tr>
       
   387 			</table>
       
   388 			<?php if ( ! $this->hide_pro_tabs ) { ?>
       
   389 				<div class="bws_pro_version_bloc">
       
   390 					<div class="bws_pro_version_table_bloc">
       
   391 						<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php esc_html_e( 'Close', 'portfolio' ); ?>"></button>
       
   392 						<div class="bws_table_bg"></div>
       
   393 						<table class="form-table bws_pro_version">
       
   394 							<tr valign="top">
       
   395 								<th scope="row"><?php esc_html_e( 'Slider Image Size', 'portfolio' ); ?> </th>
       
   396 								<td>
       
   397 									<select disabled="disabled" name="prtfl_image_size_slider">
       
   398 										<option value="large">Large (1024 × 1024)</option>
       
   399 									</select>
       
   400 									<div class="bws_info"><?php esc_html_e( 'Maximum slider image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
       
   401 								</td>
       
   402 							</tr>
       
   403 							<tr valign="top">
       
   404 								<th scope="row"><?php esc_html_e( 'Sort Projects Option', 'portfolio' ); ?></th>
       
   405 								<td>
       
   406 									<label>
       
   407 										<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>
       
   408 									</label>
       
   409 								</td>
       
   410 							</tr>
       
   411 						</table>
       
   412 					</div>
       
   413 					<?php $this->bws_pro_block_links(); ?>
       
   414 				</div>
       
   415 			<?php } ?>
       
   416 			<table class="form-table">
       
   417 				<tr valign="top">
       
   418 					<th scope="row"><?php esc_html_e( 'Sort Projects by', 'portfolio' ); ?></th>
       
   419 					<td>
       
   420 						<select name="prtfl_order_by">
       
   421 							<option value="ID" <?php selected( 'ID', $this->options['order_by'] ); ?>><?php esc_html_e( 'Project ID', 'portfolio' ); ?></option>
       
   422 							<option value="title" <?php selected( 'title', $this->options['order_by'] ); ?>><?php esc_html_e( 'Title', 'portfolio' ); ?></option>
       
   423 							<option value="date" <?php selected( 'date', $this->options['order_by'] ); ?>><?php esc_html_e( 'Date', 'portfolio' ); ?></option>
       
   424 							<option value="modified" <?php selected( 'modified', $this->options['order_by'] ); ?>><?php esc_html_e( 'Last modified date', 'portfolio' ); ?></option>
       
   425 							<option value="comment_count" <?php selected( 'comment_count', $this->options['order_by'] ); ?>><?php esc_html_e( 'Comment count', 'portfolio' ); ?></option>	
       
   426 							<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>
       
   427 							<option value="author" <?php selected( 'author', $this->options['order_by'] ); ?>><?php esc_html_e( 'Author', 'portfolio' ); ?></option>	
       
   428 							<option value="rand" <?php selected( 'rand', $this->options['order_by'] ); ?>><?php esc_html_e( 'Random', 'portfolio' ); ?></option>							
       
   429 						</select>
       
   430 						<div class="bws_info"><?php esc_html_e( 'Select projects sorting order in your portfolio page.', 'portfolio' ); ?></div>
       
   431 					</td>
       
   432 				</tr>
       
   433 				<tr valign="top">
       
   434 					<th scope="row"><?php esc_html_e( 'Arrange Projects by', 'portfolio' ); ?></th>
       
   435 					<td>
       
   436 						<fieldset>
       
   437 							<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>
       
   438 							<br />
       
   439 							<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>
       
   440 						</fieldset>
       
   441 					</td>
       
   442 				</tr>
       
   443 			</table>
       
   444 			<?php if ( ! $this->hide_pro_tabs ) { ?>
       
   445 				<div class="bws_pro_version_bloc">
       
   446 					<div class="bws_pro_version_table_bloc">
       
   447 						<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php esc_html_e( 'Close', 'portfolio' ); ?>"></button>
       
   448 						<div class="bws_table_bg"></div>
       
   449 						<table class="form-table bws_pro_version">
       
   450 							<tr valign="top">
       
   451 								<th scope="row"><?php esc_html_e( 'Lightbox Helper', 'portfolio' ); ?></th>
       
   452 								<td>
       
   453 									<input disabled type="checkbox" name="" /> <span class="bws_info"><?php esc_html_e( 'Enable to use a lightbox helper navigation between images.', 'portfolio' ); ?></span>
       
   454 								</td>
       
   455 							</tr>
       
   456 							<tr valign="top">
       
   457 								<th scope="row"><?php esc_html_e( 'Lightbox Helper Type', 'portfolio' ); ?></th>
       
   458 								<td>
       
   459 									<select disabled name="">
       
   460 										<option><?php esc_html_e( 'Thumbnails', 'portfolio' ); ?></option>
       
   461 										<option><?php esc_html_e( 'Buttons', 'portfolio' ); ?></option>
       
   462 									</select>
       
   463 								</td>
       
   464 							</tr>
       
   465 						</table>
       
   466 					</div>
       
   467 					<?php $this->bws_pro_block_links(); ?>
       
   468 				</div>
       
   469 			<?php } ?>
       
   470 			<table class="form-table">
       
   471 				<tr valign="top">
       
   472 					<th scope="row"><?php esc_html_e( 'Text Link', 'portfolio' ); ?></th>
       
   473 					<td>
       
   474 						<label>
       
   475 							<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>
       
   476 						</label>
       
   477 					</td>
       
   478 				</tr>
       
   479 				<tr>
       
   480 					<th scope="row"><?php esc_html_e( 'Automatic Mailout when Publishing a New:', 'portfolio' ); ?></th>
       
   481 					<td>
       
   482 						<?php
       
   483 						if ( array_key_exists( 'sender-pro/sender-pro.php', $this->all_plugins ) ) {
       
   484 							if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) {
       
   485 								?>
       
   486 								<fieldset>
       
   487 									<label>
       
   488 										<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'] ) ); ?> />&nbsp<?php esc_html_e( 'Projects', 'portfolio' ); ?>
       
   489 									</label><br />
       
   490 									<div data-post-type="bws-portfolio">
       
   491 										<p><?php sndr_distribution_list_select( $sndr_options['group_for_post'], 'bws-portfolio' ); ?></p>
       
   492 										<p><?php sndr_letters_list_select( $sndr_options['letter_for_post'], 'bws-portfolio' ); ?></p>
       
   493 										<p>
       
   494 											<?php
       
   495 											sndr_priorities_list( $sndr_options['priority_for_post_letters'], '', 'bws-portfolio' );
       
   496 											esc_html_e( 'Select mailout priority', 'portfolio' );
       
   497 											?>
       
   498 											<br /><span class="bws_info"><?php esc_html_e( 'Less number - higher priority', 'portfolio' ); ?></span>
       
   499 										</p><br/>
       
   500 									</div>
       
   501 								</fieldset>
       
   502 							<?php } else { ?>
       
   503 								<input disabled="disabled" type="checkbox" name="prtfl_sndr_mailout" />&nbsp
       
   504 								<span class="bws_info"><?php esc_html_e( 'Enable to automatic mailout when publishing a new bws-portfolios and tips. Sender Pro plugin is required.', 'portfolio' ); ?> <a href="https://bestwebsoft.com/products/wordpress/plugins/sender/"><?php esc_html_e( 'Activate Now', 'portfolio' ); ?></a></span><br />
       
   505 								<?php
       
   506 							}
       
   507 						} else {
       
   508 							?>
       
   509 							<input disabled="disabled" type="checkbox" name="prtfl_sndr_mailout" />&nbsp
       
   510 							<span class="bws_info"><?php esc_html_e( 'Enable to automatic mailout when publishing a new bws-portfolios and tips. Sender Pro plugin is required.', 'portfolio' ); ?> <a href="https://bestwebsoft.com/products/wordpress/plugins/sender/"><?php esc_html_e( 'Install Now', 'portfolio' ); ?></a></span><br />
       
   511 						<?php } ?>
       
   512 
       
   513 					</td>
       
   514 				</tr>
       
   515 			</table>
       
   516 			<?php wp_nonce_field( 'prtfl_settings', 'prtfl_settings_nonce' ); ?>
       
   517 			<?php
       
   518 		}
       
   519 
       
   520 		/**
       
   521 		 * Display tab Project
       
   522 		 */
       
   523 		public function tab_project() {
       
   524 			?>
       
   525 			<h3 class="bws_tab_label"><?php esc_html_e( 'Single Project Settings', 'portfolio' ); ?></h3>
       
   526 			<?php $this->help_phrase(); ?>
       
   527 			<hr>
       
   528 			<table class="form-table">
       
   529 				<tr valign="top">
       
   530 					<th scope="row" class="prtfl_table_project"><?php esc_html_e( 'Projects Fields', 'portfolio' ); ?> </th>
       
   531 					<td>
       
   532 						<fieldset>
       
   533 							<?php foreach ( $this->fields as $field_key => $field_title ) { ?>
       
   534 								<label class="prtfl_label_project">
       
   535 									<input<?php echo esc_html( $this->change_permission_attr ); ?> type="checkbox" name="prtfl_<?php echo esc_attr( $field_key ); ?>_additional_field" value="1" <?php checked( 1, $this->options[ $field_key . '_additional_field' ] ); ?> /> <?php echo esc_html( $field_title ); ?>
       
   536 									<br>
       
   537 									<input<?php echo esc_html( $this->change_permission_attr ); ?> class="prtfl_input_project" type="text" name="prtfl_<?php echo esc_attr( $field_key ); ?>_text_field" maxlength="250" value="<?php echo esc_html( $this->options[ $field_key . '_text_field' ] ); ?>" />
       
   538 								</label>
       
   539 								<br />
       
   540 							<?php } ?>
       
   541 							<label class="prtfl_label_project">
       
   542 								<input<?php echo esc_html( $this->change_permission_attr ); ?> type="checkbox" name="prtfl_svn_additional_field" value="1" <?php checked( 1, $this->options['svn_additional_field'] ); ?> /> <?php esc_html_e( 'Source Files, URL', 'portfolio' ); ?>
       
   543 							</label>
       
   544 							<label class="prtfl_label_project" id="prtfl_non_logged">
       
   545 								<input<?php echo esc_html( $this->change_permission_attr ); ?> type="checkbox" name="prtfl_svn_additional_field_for_non_logged" value="1" <?php checked( 1, $this->options['svn_additional_field_for_non_logged'] ); ?> /> <?php esc_html_e( 'Display only for logged-in users', 'portfolio' ); ?>
       
   546 							</label> 
       
   547 							<label class="prtfl_label_project">
       
   548 								<input<?php echo esc_html( $this->change_permission_attr ); ?> class="prtfl_input_project" type="text" name="prtfl_svn_text_field" maxlength="250" value= "<?php echo esc_html( $this->options['svn_text_field'] ); ?>" />
       
   549 							</label>
       
   550 							<label class="prtfl_label_project">
       
   551 								<?php esc_html_e( '"More screenshots" block', 'portfolio' ); ?>
       
   552 								<br>
       
   553 								<input class="prtfl_input_project" type="text" name="prtfl_screenshot_text_field" maxlength="250" value="<?php echo esc_html( $this->options['screenshot_text_field'] ); ?>" />
       
   554 							</label>
       
   555 						</fieldset>
       
   556 					</td>
       
   557 				</tr>
       
   558 			</table>
       
   559 			<?php if ( ! $this->hide_pro_tabs ) { ?>
       
   560 				<div class="bws_pro_version_bloc">
       
   561 					<div class="bws_pro_version_table_bloc">
       
   562 						<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php esc_html_e( 'Close', 'portfolio' ); ?>"></button>
       
   563 						<div class="bws_table_bg"></div>
       
   564 						<table class="form-table bws_pro_version">
       
   565 							<tr>
       
   566 								<th scope="row" class="prtfl_table_project"><?php esc_html_e( 'Projects Fields', 'portfolio' ); ?></th>
       
   567 								<td>
       
   568 									<fieldset>
       
   569 										<label class="prtfl_label_project">
       
   570 											<input type="checkbox" name="prtfl_categories_additional_field" value="1" disabled="disabled" /> <?php esc_html_e( 'Categories', 'portfolio' ); ?><br />
       
   571 											<input class="prtfl_input_project" type="text" name="prtfl_categories_text_field" value="<?php esc_html_e( 'Categories', 'portfolio' ); ?>:" disabled="disabled" />
       
   572 										</label><br />
       
   573 										<label class="prtfl_label_project">
       
   574 											<input type="checkbox" name="prtfl_sectors_additional_field" value="1" disabled="disabled" /> <?php esc_html_e( 'Sectors', 'portfolio' ); ?><br />
       
   575 											<input class="prtfl_input_project" type="text" name="prtfl_sectors_text_field" value="<?php esc_html_e( 'Sectors', 'portfolio' ); ?>:" disabled="disabled" />
       
   576 										</label><br />
       
   577 										<label class="prtfl_label_project">
       
   578 											<input type="checkbox" name="prtfl_services_additional_field" value="1" disabled="disabled" /> <?php esc_html_e( 'Services', 'portfolio' ); ?><br />
       
   579 											<input class="prtfl_input_project" type="text" name="prtfl_services_text_field" value="<?php esc_html_e( 'Services', 'portfolio' ); ?>:" disabled="disabled" />
       
   580 										</label><br />
       
   581 										<label class="prtfl_label_project">
       
   582 											<input type="checkbox" name="prtfl_client_additional_field" value="1" disabled="disabled" /> <?php esc_html_e( 'Client', 'portfolio' ); ?><br />
       
   583 											<input class="prtfl_input_project" type="text" name="prtfl_client_text_field" value="<?php esc_html_e( 'Client', 'portfolio' ); ?>:" disabled="disabled" />
       
   584 										</label><br />
       
   585 										<label><input type="checkbox" name="prtfl_disbable_screenshot_block" value="1" disabled="disabled" /> <?php esc_html_e( '"More screenshots" block', 'portfolio' ); ?></label><br />
       
   586 									</fieldset>
       
   587 								</td>
       
   588 							</tr>
       
   589 						</table>
       
   590 					</div>
       
   591 					<?php $this->bws_pro_block_links(); ?>
       
   592 				</div>
       
   593 				<?php
       
   594 			}
       
   595 		}
       
   596 
       
   597 		/**
       
   598 		 * Add Demo data
       
   599 		 */
       
   600 		public function additional_import_export_options() {
       
   601 			?>
       
   602 			<table class="form-table">
       
   603 				<tr valign="top">
       
   604 					<th scope="row"><?php esc_html_e( 'Demo Data', 'portfolio' ); ?></th>
       
   605 					<td>
       
   606 						<?php $this->demo_data->bws_show_demo_button( __( 'Install demo data to create portfolio projects with images, post with shortcodes and page with a list of all portfolio projects.', 'portfolio' ) ); ?>
       
   607 					</td>
       
   608 				</tr>
       
   609 			</table>
       
   610 			<?php
       
   611 		}
       
   612 
       
   613 		/**
       
   614 		 * Display custom options on the 'misc' tab
       
   615 		 *
       
   616 		 * @access public
       
   617 		 */
       
   618 		public function additional_misc_options_affected() {
       
   619 			global $wp_version;
       
   620 			if ( ! $this->all_plugins ) {
       
   621 				if ( ! function_exists( 'get_plugins' ) ) {
       
   622 					require_once ABSPATH . 'wp-admin/includes/plugin.php';
       
   623 				}
       
   624 				$this->all_plugins = get_plugins();
       
   625 			}
       
   626 			if ( $this->options['post_type_name'] !== $this->default_options['post_type_name'] ) {
       
   627 				?>
       
   628 				<tr valign="top">
       
   629 					<th scope="row"><?php esc_html_e( 'Portfolio Post Type', 'portfolio' ); ?></th>
       
   630 					<td>
       
   631 						<input type="checkbox" name="prtfl_rename_post_type" value="1" />
       
   632 						<span class="bws_info">
       
   633 							<?php esc_html_e( 'Enable to avoid conflicts with other portfolio plugins installed. All portfolio created earlier will stay unchanged. However, after enabling we recommend to check settings of other plugins where "portfolio" post type is used.', 'portfolio' ); ?>
       
   634 						</span>
       
   635 					</td>
       
   636 				</tr>
       
   637 			<?php } ?>
       
   638 			<tr valign="top">
       
   639 				<th scope="row"><?php esc_html_e( 'Portfolio Slug', 'portfolio' ); ?></th>
       
   640 				<td>
       
   641 					<input type="text" name="prtfl_slug" maxlength="100" value="<?php echo esc_attr( $this->options['slug'] ); ?>" />
       
   642 					<div class="bws_info"><?php esc_html_e( 'Enter the unique portfolio slug.', 'portfolio' ); ?></div>
       
   643 				</td>
       
   644 			</tr>
       
   645 			<tr valign="top">
       
   646 				<th scope="row"><?php esc_html_e( 'Search Portfolio Projects', 'portfolio' ); ?></th>
       
   647 				<td>
       
   648 					<?php
       
   649 					$disabled = '';
       
   650 					$checked  = '';
       
   651 					$link     = '';
       
   652 					if ( array_key_exists( 'custom-search-plugin/custom-search-plugin.php', $this->all_plugins ) || array_key_exists( 'custom-search-pro/custom-search-pro.php', $this->all_plugins ) ) {
       
   653 						if ( ! is_plugin_active( 'custom-search-plugin/custom-search-plugin.php' ) && ! is_plugin_active( 'custom-search-pro/custom-search-pro.php' ) ) {
       
   654 							$disabled = ' disabled="disabled"';
       
   655 							$link     = '<a href="' . admin_url( 'plugins.php' ) . '">' . __( 'Activate Now', 'portfolio' ) . '</a>';
       
   656 						}
       
   657 						if ( isset( $this->cstmsrch_options['output_order'] ) ) {
       
   658 							foreach ( $this->cstmsrch_options['output_order'] as $key => $item ) {
       
   659 								if ( $item['name'] === $this->options['post_type_name'] && 'post_type' === $item['type'] ) {
       
   660 									if ( $item['enabled'] ) {
       
   661 										$checked = ' checked="checked"';
       
   662 									}
       
   663 									break;
       
   664 								}
       
   665 							}
       
   666 						} elseif ( ! empty( $this->cstmsrch_options['post_types'] ) && in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
       
   667 							$checked = ' checked="checked"';
       
   668 						}
       
   669 					} else {
       
   670 						$disabled = ' disabled="disabled"';
       
   671 						$link     = '<a href="https://bestwebsoft.com/products/wordpress/plugins/custom-search/?k=75e20470c8716645cf65febf9d30f269&amp;pn=' . $this->link_pn . '&amp;v=' . $this->plugins_info['Version'] . '&amp;wp_v=' . $wp_version . '" target="_blank">' . __( 'Install Now', 'portfolio' ) . '</a>';
       
   672 					}
       
   673 					?>
       
   674 					<input type="checkbox" name="prtfl_add_to_search" value="1"<?php echo esc_html( $disabled . $checked ); ?> />
       
   675 					<span class="bws_info"><?php esc_html_e( 'Enable to include portfolio projects to your website search.', 'portfolio' ); ?> <?php printf( esc_html__( '%s plugin is required.', 'portfolio' ), 'Custom Search' ); ?> <?php echo esc_url( $link ); ?></span>					
       
   676 				</td>
       
   677 			</tr>
       
   678 			<?php
       
   679 		}
       
   680 
       
   681 		/**
       
   682 		 * Display custom metabox
       
   683 		 *
       
   684 		 * @access public
       
   685 		 */
       
   686 		public function display_metabox() {
       
   687 			?>
       
   688 			<div class="postbox">
       
   689 				<h3 class="hndle">
       
   690 					<?php esc_html_e( 'Portfolio Shortcode', 'portfolio' ); ?>
       
   691 				</h3>
       
   692 				<div class="inside">
       
   693 					<?php esc_html_e( 'Add the latest portfolio projects using the following shortcode (where * is a number of projects to display):', 'portfolio' ); ?>
       
   694 					<?php bws_shortcode_output( '[latest_portfolio_items count=*]' ); ?>
       
   695 				</div>
       
   696 			</div>
       
   697 			<?php
       
   698 		}
       
   699 	}
       
   700 }