wp/wp-content/plugins/portfolio/inc/class-prtfl-settings.php
changeset 7 cf61fcea0001
child 12 d8a8807227e4
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     1 <?php
       
     2 /**
       
     3  * Displays the content on the plugin settings page
       
     4  */
       
     5 
       
     6 require_once( dirname( dirname( __FILE__ ) ) . '/bws_menu/class-bws-settings.php' );
       
     7 
       
     8 if ( ! class_exists( 'Prtfl_Settings_Tabs' ) ) {
       
     9 	class Prtfl_Settings_Tabs extends Bws_Settings_Tabs {
       
    10 		public $wp_image_sizes = array();
       
    11 		public $cstmsrch_options, $fields;
       
    12 
       
    13 		/**
       
    14 		 * Constructor.
       
    15 		 *
       
    16 		 * @access public
       
    17 		 *
       
    18 		 * @see Bws_Settings_Tabs::__construct() for more information on default arguments.
       
    19 		 *
       
    20 		 * @param string $plugin_basename
       
    21 		 */
       
    22 		public function __construct( $plugin_basename ) {
       
    23 			global $prtfl_options, $prtfl_plugin_info, $prtfl_BWS_demo_data;
       
    24 
       
    25 			$tabs = array(
       
    26 				'settings' 		=> array( 'label' => __( 'Settings', 'portfolio' ) ),
       
    27 				'misc' 			=> array( 'label' => __( 'Misc', 'portfolio' ) ),
       
    28 				'custom_code' 	=> array( 'label' => __( 'Custom Code', 'portfolio' ) ),
       
    29 				'import-export' => array( 'label' => __( 'Import / Export', 'portfolio' ) ),
       
    30 				'license'		=> array( 'label' => __( 'License Key', 'portfolio' ) ),
       
    31 			);
       
    32 
       
    33 			parent::__construct( array(
       
    34 				'plugin_basename' 	 => $plugin_basename,
       
    35 				'plugins_info'		 => $prtfl_plugin_info,
       
    36 				'prefix' 			 => 'prtfl',
       
    37 				'default_options' 	 => prtfl_get_options_default(),
       
    38 				'options' 			 => $prtfl_options,
       
    39 				'tabs' 				 => $tabs,
       
    40 				'wp_slug'			 => 'portfolio',
       
    41 				'demo_data'			 => $prtfl_BWS_demo_data,
       
    42 				'pro_page' 			 => 'edit.php?post_type=bws-portfolio&page=portfolio-pro.php',
       
    43 				'bws_license_plugin' => 'portfolio-pro/portfolio-pro.php',
       
    44 				'link_key' 			 => 'f047e20c92c972c398187a4f70240285',
       
    45 				'link_pn' 			 => '74',
       
    46 			) );
       
    47 
       
    48 			$wp_sizes = get_intermediate_image_sizes();
       
    49 
       
    50 			foreach ( (array) $wp_sizes as $size ) {
       
    51 				if ( ! array_key_exists( $size, $prtfl_options['custom_size_px'] ) ) {
       
    52 					if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
       
    53 						$width  = absint( $_wp_additional_image_sizes[ $size ]['width'] );
       
    54 						$height = absint( $_wp_additional_image_sizes[ $size ]['height'] );
       
    55 					} else {
       
    56 						$width  = absint( get_option( $size . '_size_w' ) );
       
    57 						$height = absint( get_option( $size . '_size_h' ) );
       
    58 					}
       
    59 
       
    60 					if ( ! $width && ! $height ) {
       
    61 						$this->wp_image_sizes[] = array(
       
    62 							'value'  => $size,
       
    63 							'name'   => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ),
       
    64 						);
       
    65 					} else {
       
    66 						$this->wp_image_sizes[] = array(
       
    67 							'value'  => $size,
       
    68 							'name'   => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ) . ' (' . $width . ' &#215; ' . $height . ')',
       
    69 							'width'  => $width,
       
    70 							'height' => $height
       
    71 						);
       
    72 					}
       
    73 				}
       
    74 			}
       
    75 
       
    76 			$this->cstmsrch_options = get_option( 'cstmsrch_options' );
       
    77 
       
    78 			$this->fields = array(
       
    79 				'executor'			=> __( 'Executors', 'portfolio' ),
       
    80 				'technologies'		=> __( 'Technologies', 'portfolio' ),
       
    81 				'date'				=> __( 'Date of completion', 'portfolio' ),
       
    82 				'link'				=> __( 'Link', 'portfolio' ),
       
    83 				'shrdescription'	=> __( 'Short Description', 'portfolio' ),
       
    84 				'description'		=> __( 'Description', 'portfolio' ),
       
    85 				'svn'				=> __( 'SVN URL', 'portfolio' )
       
    86 			);
       
    87 
       
    88 			add_action( get_parent_class( $this ) . '_display_custom_messages', array( $this, 'display_custom_messages' ) );
       
    89 			add_action( get_parent_class( $this ) . '_additional_misc_options_affected', array( $this, 'additional_misc_options_affected' ) );
       
    90 			add_action( get_parent_class( $this ) . '_additional_import_export_options', array( $this, 'additional_import_export_options' ) );
       
    91 			add_action( get_parent_class( $this ) . '_display_metabox', array( $this, 'display_metabox' ) );
       
    92 		}
       
    93 
       
    94 		/**
       
    95 		 * Save plugin options to the database
       
    96 		 * @access public
       
    97 		 * @param  void
       
    98 		 * @return array    The action results
       
    99 		 */
       
   100 		public function save_options() {
       
   101 
       
   102 			$this->options["custom_image_row_count"] = intval( $_POST['prtfl_custom_image_row_count'] );
       
   103 			if ( 1 > $this->options["custom_image_row_count"] )
       
   104 				$this->options["custom_image_row_count"] = 1;
       
   105 
       
   106 			$new_image_size_photo 		= esc_attr( $_POST['prtfl_image_size_photo'] );
       
   107 			$custom_image_size_w_photo 	= intval( $_POST['prtfl_custom_image_size_w_photo'] );
       
   108 			$custom_image_size_h_photo 	= intval( $_POST['prtfl_custom_image_size_h_photo'] );
       
   109 			$custom_size_px_photo 		= array( $custom_image_size_w_photo, $custom_image_size_h_photo );
       
   110 			if ( 'portfolio-photo-thumb' == $new_image_size_photo ) {
       
   111 				if ( $new_image_size_photo != $this->options['image_size_photo'] ) {
       
   112 					$need_image_update = true;
       
   113 				} else {
       
   114 					foreach ( $custom_size_px_photo as $key => $value ) {
       
   115 						if ( $value != $this->options['custom_size_px']['portfolio-photo-thumb'][ $key ] ) {
       
   116 							$need_image_update = true;
       
   117 							break;
       
   118 						}
       
   119 					}
       
   120 				}
       
   121 			}
       
   122 			$this->options['custom_size_px']['portfolio-photo-thumb'] = $custom_size_px_photo;
       
   123 			$this->options['image_size_photo'] 				= $new_image_size_photo;
       
   124 
       
   125 			$new_image_size_album 		= esc_attr( $_POST['prtfl_image_size_album'] );
       
   126 			$custom_image_size_w_album 	= intval( $_POST['prtfl_custom_image_size_w_album'] );
       
   127 			$custom_image_size_h_album 	= intval( $_POST['prtfl_custom_image_size_h_album'] );
       
   128 			$custom_size_px_album 		= array( $custom_image_size_w_album, $custom_image_size_h_album );
       
   129 			if ( 'portfolio-thumb' == $new_image_size_album ) {
       
   130 				if ( $new_image_size_album != $this->options['image_size_album'] ) {
       
   131 					$need_image_update = true;
       
   132 				} else {
       
   133 					foreach ( $custom_size_px_album as $key => $value ) {
       
   134 						if ( $value != $this->options['custom_size_px']['portfolio-thumb'][ $key ] ) {
       
   135 							$need_image_update = true;
       
   136 							break;
       
   137 						}
       
   138 					}
       
   139 				}
       
   140 			}
       
   141 
       
   142 			$this->options['custom_size_px']['portfolio-thumb'] = $custom_size_px_album;
       
   143 			$this->options['image_size_album'] 				= $new_image_size_album;
       
   144 
       
   145 			if ( ! empty( $_POST['prtfl_page_id_portfolio_template'] ) && $this->options['page_id_portfolio_template'] != intval( $_POST['prtfl_page_id_portfolio_template'] ) ) {
       
   146 				/* for rewrite */
       
   147 				$this->options["flush_rewrite_rules"] = 1;
       
   148 				$this->options['page_id_portfolio_template'] = intval( $_POST['prtfl_page_id_portfolio_template'] );
       
   149 			}
       
   150 
       
   151 			$this->options["order_by"]		= esc_attr( $_POST['prtfl_order_by'] );
       
   152 			$this->options["order"]			= esc_attr( $_POST['prtfl_order'] );
       
   153 
       
   154 			if ( ! empty( $need_image_update ) ) {
       
   155 				$this->options['need_image_update'] = __( 'Custom image size was changed. You need to update project images.', 'portfolio' );
       
   156 			}
       
   157 
       
   158 			$this->options["link_additional_field_for_non_registered"] = isset( $_REQUEST["prtfl_link_additional_field_for_non_registered"] ) ? 1 : 0;
       
   159 
       
   160 			foreach ( $this->fields as $field_key => $field_title ) {
       
   161 				$this->options[ $field_key . '_additional_field'] = isset( $_REQUEST['prtfl_' . $field_key . '_additional_field'] ) ? 1 : 0;
       
   162 				$this->options[ $field_key . '_text_field'] = stripslashes( esc_html( $_REQUEST['prtfl_' . $field_key . '_text_field'] ) );
       
   163 			}
       
   164 
       
   165 			$this->options['screenshot_text_field'] = stripslashes( esc_html( $_REQUEST['prtfl_screenshot_text_field'] ) );
       
   166 
       
   167 			$slug = strtolower( trim( stripslashes( esc_html( $_POST['prtfl_slug'] ) ) ) );
       
   168 			$slug = preg_replace( "/[^a-z0-9\s-]/", "", $slug );
       
   169 			$slug = trim( preg_replace( "/[\s-]+/", " ", $slug ) );
       
   170 			$slug = preg_replace( "/\s/", "-", $slug );
       
   171 			if ( $this->options["slug"] != $slug ) {
       
   172 				$this->options["flush_rewrite_rules"] = 1;
       
   173 			}
       
   174 			$this->options["slug"] = $slug;
       
   175 
       
   176 			/**
       
   177 			 * rewriting post types name with unique one from default options
       
   178 			 */
       
   179 			if ( ! empty( $_POST['prtfl_rename_post_type'] ) ) {
       
   180 				global $wpdb;
       
   181 				$wpdb->update(
       
   182 					$wpdb->prefix . 'posts',
       
   183 					array( 'post_type' => $this->default_options['post_type_name'] ),
       
   184 					array( 'post_type' => $this->options['post_type_name'] )
       
   185 				);
       
   186 				$this->options['post_type_name'] = $this->default_options['post_type_name'];
       
   187 			}
       
   188 
       
   189 			if ( ! empty( $this->cstmsrch_options ) ) {
       
   190 				if ( isset( $this->cstmsrch_options['output_order'] ) ) {
       
   191 					$is_enabled = isset( $_POST['prtfl_add_to_search'] ) ? 1 : 0;
       
   192 					$post_type_exist = false;
       
   193 					foreach ( $this->cstmsrch_options['output_order'] as $key => $item ) {
       
   194 						if ( $item['name'] == $this->options['post_type_name'] && 'post_type' == $item['type'] ) {
       
   195 							$post_type_exist = true;
       
   196 							if ( $item['enabled'] != $is_enabled ) {
       
   197 								$this->cstmsrch_options['output_order'][ $key ]['enabled'] = $is_enabled;
       
   198 								$cstmsrch_options_update = true;
       
   199 							}
       
   200 							break;
       
   201 						}
       
   202 					}
       
   203 					if ( ! $post_type_exist ) {
       
   204 						$this->cstmsrch_options['output_order'][] = array(
       
   205 							'name' 		=> $this->options['post_type_name'],
       
   206 							'type' 		=> 'post_type',
       
   207 							'enabled' 	=> $is_enabled );
       
   208 						$cstmsrch_options_update = true;
       
   209 					}
       
   210 				} elseif ( isset( $this->cstmsrch_options['post_types'] ) ) {
       
   211 					if ( isset( $_POST['prtfl_add_to_search'] ) && ! in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
       
   212 						array_push( $this->cstmsrch_options['post_types'], $this->options['post_type_name'] );
       
   213 						$cstmsrch_options_update = true;
       
   214 					} elseif ( ! isset( $_POST['prtfl_add_to_search'] ) && in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
       
   215 						unset( $this->cstmsrch_options['post_types'][ array_search( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ] );
       
   216 						$cstmsrch_options_update = true;
       
   217 					}
       
   218 				}
       
   219 				if ( isset( $cstmsrch_options_update ) ) {
       
   220 					update_option( 'cstmsrch_options', $this->cstmsrch_options );
       
   221 				}
       
   222 			}
       
   223 
       
   224 			update_option( 'prtfl_options', $this->options );
       
   225 			$message = __( "Settings saved.", 'portfolio' );
       
   226 
       
   227 			return compact( 'message', 'notice', 'error' );
       
   228 		}
       
   229 
       
   230 		/**
       
   231 		 * Display custom error\message\notice
       
   232 		 * @access public
       
   233 		 * @param  $save_results - array with error\message\notice
       
   234 		 * @return void
       
   235 		 */
       
   236 		public function display_custom_messages( $save_results ) { ?>
       
   237 			<noscript><div class="error below-h2"><p><strong><?php _e( "Please enable JavaScript in Your browser.", 'portfolio' ); ?></strong></p></div></noscript>
       
   238 			<?php if ( ! empty( $this->options['need_image_update'] ) ) { ?>
       
   239 				<div class="updated bws-notice inline prtfl_image_update_message">
       
   240 					<p>
       
   241 						<?php echo $this->options['need_image_update']; ?>
       
   242 						<input type="button" value="<?php _e( 'Update Images', 'portfolio' ); ?>" id="prtfl_ajax_update_images" name="ajax_update_images" class="button" />
       
   243 					</p>
       
   244 				</div>
       
   245 			<?php }
       
   246 		}
       
   247 
       
   248 		/**
       
   249 		 *
       
   250 		 */
       
   251 		public function tab_settings() { ?>
       
   252 			<h3 class="bws_tab_label"><?php _e( 'Portfolio Settings', 'portfolio' ); ?></h3>
       
   253 			<?php $this->help_phrase(); ?>
       
   254 			<hr>
       
   255 			<table class="form-table">
       
   256 				<tr valign="top">
       
   257 					<th scope="row"><?php _e( 'Number of Columns', 'portfolio' ); ?> </th>
       
   258 					<td>
       
   259 						<input type="number" name="prtfl_custom_image_row_count" min="1" max="10000" value="<?php echo $this->options["custom_image_row_count"]; ?>" /> <?php _e( 'columns', 'portfolio' ); ?>
       
   260 						 <div class="bws_info"><?php printf( __( 'Number of image columns (default is %s).', 'portfolio' ), '3' ); ?></div>
       
   261 					</td>
       
   262 				</tr>
       
   263 				<tr valign="top">
       
   264 					<th scope="row"><?php _e( 'Image Size', 'portfolio' ); ?></th>
       
   265 					<td>
       
   266 						<select name="prtfl_image_size_photo">
       
   267 							<?php foreach ( $this->wp_image_sizes as $data ) { ?>
       
   268 								<option value="<?php echo $data['value']; ?>" <?php selected( $data['value'], $this->options['image_size_photo'] ); ?>><?php echo $data['name']; ?></option>
       
   269 							<?php } ?>
       
   270 							<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 _e( 'Custom', 'portfolio' ); ?></option>
       
   271 						</select>
       
   272 						<div class="bws_info"><?php _e( 'Maximum portfolio image size. "Custom" uses the Image Dimensions values.', 'portfolio' ); ?></div>
       
   273 					</td>
       
   274 				</tr>
       
   275 				<tr valign="top" class="prtfl_for_custom_image_size">
       
   276 					<th scope="row"><?php _e( 'Custom Image Size', 'portfolio' ); ?> </th>
       
   277 					<td>
       
   278 						<input type="number" name="prtfl_custom_image_size_w_photo" min="1" max="10000" value="<?php echo $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 $this->options['custom_size_px']['portfolio-photo-thumb'][1]; ?>" /> px <div class="bws_info"><?php _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>
       
   279 					</td>
       
   280 				</tr>
       
   281 				<tr valign="top">
       
   282 					<th scope="row"><?php _e( 'Portfolio Page', 'portfolio' ); ?></th>
       
   283 					<td>
       
   284 						<?php wp_dropdown_pages( array(
       
   285 							'depth'                 => 0,
       
   286 							'selected'              => $this->options['page_id_portfolio_template'],
       
   287 							'name'                  => 'prtfl_page_id_portfolio_template',
       
   288 							'show_option_none'		=> '...'
       
   289 						) ); ?>
       
   290 						<div class="bws_info"><?php _e( 'Base page where all existing projects will be displayed.' , 'portfolio'); ?></div>
       
   291 					</td>
       
   292 				</tr>
       
   293 				<tr valign="top">
       
   294 					<th scope="row"><?php _e( 'Cover Image Size', 'portfolio' ); ?> </th>
       
   295 					<td>
       
   296 						<select name="prtfl_image_size_album">
       
   297 							<?php foreach ( $this->wp_image_sizes as $data ) { ?>
       
   298 								<option value="<?php echo $data['value']; ?>" <?php selected( $data['value'], $this->options['image_size_album'] ); ?>><?php echo $data['name']; ?></option>
       
   299 							<?php } ?>
       
   300 							<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 _e( 'Custom', 'portfolio' ); ?></option>
       
   301 						</select>
       
   302 						<div class="bws_info"><?php _e( 'Maximum cover image size. Custom uses the Image Dimensions values.', 'portfolio' ); ?></div>
       
   303 					</td>
       
   304 				</tr>
       
   305 				<tr valign="top" class="prtfl_for_custom_image_size_album">
       
   306 					<th scope="row"><?php _e( 'Custom Cover Image Size', 'portfolio' ); ?> </th>
       
   307 					<td>
       
   308 						<input type="number" name="prtfl_custom_image_size_w_album" min="1" max="10000" value="<?php echo $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 $this->options['custom_size_px']['portfolio-thumb'][1]; ?>" /> px
       
   309 					</td>
       
   310 				</tr>
       
   311 				<tr valign="top">
       
   312 					<th scope="row"><?php _e( 'Sort Projects by', 'portfolio' ); ?></th>
       
   313 					<td>
       
   314 						<select name="prtfl_order_by">
       
   315 							<option value="ID" <?php selected( 'ID', $this->options["order_by"] ); ?>><?php _e( 'Project ID', 'portfolio' ); ?></option>
       
   316 							<option value="title" <?php selected( 'title', $this->options["order_by"] ); ?>><?php _e( 'Title', 'portfolio' ); ?></option>
       
   317 							<option value="date" <?php selected( 'date', $this->options["order_by"] ); ?>><?php _e( 'Date', 'portfolio' ); ?></option>
       
   318 							<option value="modified" <?php selected( 'modified', $this->options["order_by"] ); ?>><?php _e( 'Last modified date', 'portfolio' ); ?></option>
       
   319 							<option value="comment_count" <?php selected( 'comment_count', $this->options["order_by"] ); ?>><?php _e( 'Comment count', 'portfolio' ); ?></option>	
       
   320 							<option value="menu_order" <?php selected( 'menu_order', $this->options["order_by"] ); ?>><?php _e( 'Sorting order (the input field for sorting order)', 'portfolio' ); ?></option>
       
   321 							<option value="author" <?php selected( 'author', $this->options["order_by"] ); ?>><?php _e( 'Author', 'portfolio' ); ?></option>	
       
   322 							<option value="rand" <?php selected( 'rand', $this->options["order_by"] ); ?>><?php _e( 'Random', 'portfolio' ); ?></option>							
       
   323 						</select>
       
   324 						<div class="bws_info"><?php _e( 'Select projects sorting order in your portfolio page.', 'portfolio' ); ?></div>
       
   325 					</td>
       
   326 				</tr>
       
   327 				<tr valign="top">
       
   328 					<th scope="row"><?php _e( 'Arrange Projects by', 'portfolio' ); ?></th>
       
   329 					<td>
       
   330 						<fieldset>
       
   331 							<label><input type="radio" name="prtfl_order" value="ASC" <?php checked( 'ASC', $this->options["order"] ); ?> /> <?php _e( 'Ascending (e.g. 1, 2, 3; a, b, c)', 'portfolio' ); ?></label>
       
   332 							<br />
       
   333 							<label><input type="radio" name="prtfl_order" value="DESC" <?php checked( 'DESC', $this->options["order"] ); ?> /> <?php _e( 'Descending (e.g. 3, 2, 1; c, b, a)', 'portfolio' ); ?></label>
       
   334 						</fieldset>
       
   335 					</td>
       
   336 				</tr>
       
   337 			</table>
       
   338 			<?php if ( ! $this->hide_pro_tabs ) { ?>
       
   339 				<div class="bws_pro_version_bloc">
       
   340 					<div class="bws_pro_version_table_bloc">
       
   341 						<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'portfolio' ); ?>"></button>
       
   342 						<div class="bws_table_bg"></div>
       
   343 						<table class="form-table bws_pro_version">
       
   344 							<tr valign="top">
       
   345 								<th scope="row"><?php _e( 'Manual Sorting', 'portfolio' ); ?></th>
       
   346 								<td>
       
   347 									<label>
       
   348 										<input type="checkbox" name="prtfl_sorting_selectbox" value="1" disabled="disabled" /> <span class="bws_info"><?php _e( 'Enable to sort projects manually by date or title.', 'portfolio' ); ?></span>
       
   349 									</label>
       
   350 								</td>
       
   351 							</tr>
       
   352 							<tr valign="top">
       
   353 								<th scope="row"><?php _e( 'Lightbox Helper', 'portfolio' ); ?></th>
       
   354 								<td>
       
   355 									<input disabled type="checkbox" name="" /> <span class="bws_info"><?php _e( 'Enable to use a lightbox helper navigation between images.', 'portfolio' ); ?></span>
       
   356 								</td>
       
   357 							</tr>
       
   358 							<tr valign="top">
       
   359 								<th scope="row"><?php _e( 'Lightbox Helper Type', 'portfolio' ); ?></th>
       
   360 								<td>
       
   361 									<select disabled name="">
       
   362 										<option><?php _e( 'Thumbnails', 'portfolio' ); ?></option>
       
   363 										<option><?php _e( 'Buttons', 'portfolio' ); ?></option>
       
   364 									</select>
       
   365 								</td>
       
   366 							</tr>
       
   367 						</table>
       
   368 					</div>
       
   369 					<?php $this->bws_pro_block_links(); ?>
       
   370 				</div>
       
   371 			<?php } ?>
       
   372 			<table class="form-table">
       
   373 				<tr valign="top">
       
   374 					<th scope="row"><?php _e( 'Text Link', 'portfolio' ); ?></th>
       
   375 					<td>
       
   376 						<label>
       
   377 							<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 _e( 'Enable to display link field as a text for non-registered users.', 'portfolio' ); ?></span>
       
   378 						</label>
       
   379 					</td>
       
   380 				</tr>
       
   381 				<tr valign="top">
       
   382 					<th scope="row"><?php _e( 'Projects Fields', 'portfolio' ); ?> </th>
       
   383 					<td>
       
   384 						<fieldset>
       
   385 							<?php foreach ( $this->fields as $field_key => $field_title ) { ?>
       
   386 								<label>
       
   387 									<input<?php echo $this->change_permission_attr; ?> type="checkbox" name="prtfl_<?php echo $field_key; ?>_additional_field" value="1" <?php checked( 1, $this->options[ $field_key . '_additional_field'] ); ?> />
       
   388 									 <?php echo $field_title; ?>
       
   389 									<br>
       
   390 									<input<?php echo $this->change_permission_attr; ?> type="text" name="prtfl_<?php echo $field_key; ?>_text_field" maxlength="250" value="<?php echo $this->options[ $field_key . '_text_field']; ?>" />
       
   391 								</label>
       
   392 								<br />
       
   393 							<?php } ?>
       
   394 							<label>
       
   395 								 <?php _e( '"More screenshots" block', 'portfolio' ); ?>
       
   396 								<br>
       
   397 								<input type="text" name="prtfl_screenshot_text_field" maxlength="250" value="<?php echo $this->options["screenshot_text_field"]; ?>" />								
       
   398 							</label>
       
   399 						</fieldset>
       
   400 					</td>
       
   401 				</tr>
       
   402 			</table>
       
   403 			<?php if ( ! $this->hide_pro_tabs ) { ?>
       
   404 				<div class="bws_pro_version_bloc">
       
   405 					<div class="bws_pro_version_table_bloc">
       
   406 						<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'portfolio' ); ?>"></button>
       
   407 						<div class="bws_table_bg"></div>
       
   408 						<table class="form-table bws_pro_version">
       
   409 							<tr valign="top">
       
   410 								<th scope="row"><?php _e( 'Projects Fields', 'portfolio' ); ?></th>
       
   411 								<td>
       
   412 									<fieldset>
       
   413 										<label>
       
   414 											<input type="checkbox" name="prtfl_categories_additional_field" value="1" disabled="disabled" />
       
   415 											 <?php _e( 'Categories', 'portfolio' ); ?><br />
       
   416 											<input type="text" name="prtfl_categories_text_field" value="<?php _e( 'Categories', 'portfolio' ); ?>:" disabled="disabled" />											
       
   417 										</label><br />
       
   418 										<label>
       
   419 											<input type="checkbox" name="prtfl_sectors_additional_field" value="1" disabled="disabled" />
       
   420 											 <?php _e( 'Sectors', 'portfolio' ); ?><br />
       
   421 											<input type="text" name="prtfl_sectors_text_field" value="<?php _e( 'Sectors', 'portfolio' ); ?>:" disabled="disabled" />											
       
   422 										</label><br />
       
   423 										<label>
       
   424 											<input type="checkbox" name="prtfl_services_additional_field" value="1" disabled="disabled" />
       
   425 											 <?php _e( 'Services', 'portfolio' ); ?><br />
       
   426 											<input type="text" name="prtfl_services_text_field" value="<?php _e( 'Services', 'portfolio' ); ?>:" disabled="disabled" />											
       
   427 										</label><br />
       
   428 										<label>
       
   429 											<input type="checkbox" name="prtfl_client_additional_field" value="1" disabled="disabled" />
       
   430 											 <?php _e( 'Client', 'portfolio' ); ?><br />
       
   431 											<input type="text" name="prtfl_client_text_field" value="<?php _e( 'Client', 'portfolio' ); ?>:" disabled="disabled" />											
       
   432 										</label><br />
       
   433 										<label><input type="checkbox" name="prtfl_disbable_screenshot_block" value="1" disabled="disabled" /> <?php _e( '"More screenshots" block', 'portfolio' ); ?></label><br />
       
   434 									</fieldset>
       
   435 								</td>
       
   436 							</tr>
       
   437 						</table>
       
   438 					</div>
       
   439 					<?php $this->bws_pro_block_links(); ?>
       
   440 				</div>
       
   441 			<?php }
       
   442 		}
       
   443 
       
   444 		/**
       
   445 		 *
       
   446 		 */
       
   447 		public function additional_import_export_options() { ?>
       
   448 			<table class="form-table">
       
   449 				<tr valign="top">
       
   450 					<th scope="row"><?php _e( 'Demo Data', 'portfolio' ); ?></th>
       
   451 					<td>
       
   452 						<?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' ) ); ?>
       
   453 					</td>
       
   454 				</tr>
       
   455 			</table>
       
   456 		<?php }
       
   457 
       
   458 		/**
       
   459 		 * Display custom options on the 'misc' tab
       
   460 		 * @access public
       
   461 		 */
       
   462 		public function additional_misc_options_affected() {
       
   463 			global $wp_version;
       
   464 			if ( ! $this->all_plugins ) {
       
   465 				if ( ! function_exists( 'get_plugins' ) ) {
       
   466 					require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
       
   467 				}
       
   468 				$this->all_plugins = get_plugins();
       
   469 			}
       
   470 			if ( $this->options['post_type_name'] != $this->default_options['post_type_name'] ) { ?>
       
   471 				<tr valign="top">
       
   472 					<th scope="row"><?php _e( 'Portfolio Post Type', 'portfolio' ); ?></th>
       
   473 					<td>
       
   474 						<input type="checkbox" name="prtfl_rename_post_type" value="1" />
       
   475 						<span class="bws_info">
       
   476 							<?php _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' ); ?>
       
   477 						</span>
       
   478 					</td>
       
   479 				</tr>
       
   480 			<?php } ?>
       
   481 			<tr valign="top">
       
   482 				<th scope="row"><?php _e( 'Portfolio Slug', 'portfolio' ); ?></th>
       
   483 				<td>
       
   484 					<input type="text" name="prtfl_slug" maxlength="100" value="<?php echo $this->options["slug"]; ?>" />
       
   485 					<div class="bws_info"><?php _e( 'Enter the unique portfolio slug.', 'portfolio' ); ?></div>
       
   486 				</td>
       
   487 			</tr>
       
   488 			<tr valign="top">
       
   489 				<th scope="row"><?php _e( 'Search Portfolio Projects', 'portfolio' ); ?></th>
       
   490 				<td>
       
   491 					<?php $disabled = $checked = $link = '';
       
   492 					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 ) ) {
       
   493 						if ( ! is_plugin_active( 'custom-search-plugin/custom-search-plugin.php' ) && ! is_plugin_active( 'custom-search-pro/custom-search-pro.php' ) ) {
       
   494 							$disabled = ' disabled="disabled"';
       
   495 							$link = '<a href="' . admin_url( 'plugins.php' ) . '">' . __( 'Activate Now', 'portfolio' ) . '</a>';
       
   496 						}
       
   497 						if ( isset( $this->cstmsrch_options['output_order'] ) ) {
       
   498 							foreach ( $this->cstmsrch_options['output_order'] as $key => $item ) {
       
   499 								if ( $item['name'] == $this->options['post_type_name'] && 'post_type' == $item['type'] ) {
       
   500 									if ( $item['enabled'] ) {
       
   501 										$checked = ' checked="checked"';
       
   502 									}
       
   503 									break;
       
   504 								}
       
   505 							}
       
   506 						} elseif ( ! empty( $this->cstmsrch_options['post_types'] ) && in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
       
   507 							$checked = ' checked="checked"';
       
   508 						}
       
   509 					} else {
       
   510 						$disabled = ' disabled="disabled"';
       
   511 						$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>';
       
   512 					} ?>
       
   513 					<input type="checkbox" name="prtfl_add_to_search" value="1"<?php echo $disabled . $checked; ?> />
       
   514 					 <span class="bws_info"><?php _e( 'Enable to include portfolio projects to your website search.', 'portfolio' ); ?> <?php printf( __( '%s plugin is required.', 'portfolio' ), 'Custom Search' ); ?> <?php echo $link; ?></span>					
       
   515 				</td>
       
   516 			</tr>
       
   517 		<?php }
       
   518 
       
   519 		/**
       
   520 		 * Display custom metabox
       
   521 		 * @access public
       
   522 		 * @param  void
       
   523 		 * @return array    The action results
       
   524 		 */
       
   525 		public function display_metabox() { ?>
       
   526 			<div class="postbox">
       
   527 				<h3 class="hndle">
       
   528 					<?php _e( 'Portfolio Shortcode', 'portfolio' ); ?>
       
   529 				</h3>
       
   530 				<div class="inside">
       
   531 					<?php _e( "Add the latest portfolio projects using the following shortcode (where * is a number of projects to display):", 'portfolio' ); ?>
       
   532 					<?php bws_shortcode_output( '[latest_portfolio_items count=*]' ); ?>
       
   533 				</div>
       
   534 			</div>
       
   535 		<?php }
       
   536 	}
       
   537 }