diff -r 490d5cc509ed -r cf61fcea0001 wp/wp-content/plugins/portfolio/inc/class-prtfl-settings.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wp/wp-content/plugins/portfolio/inc/class-prtfl-settings.php Mon Oct 14 17:39:30 2019 +0200
@@ -0,0 +1,537 @@
+ array( 'label' => __( 'Settings', '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' ) ),
+ );
+
+ parent::__construct( array(
+ 'plugin_basename' => $plugin_basename,
+ 'plugins_info' => $prtfl_plugin_info,
+ 'prefix' => 'prtfl',
+ 'default_options' => prtfl_get_options_default(),
+ 'options' => $prtfl_options,
+ 'tabs' => $tabs,
+ 'wp_slug' => 'portfolio',
+ 'demo_data' => $prtfl_BWS_demo_data,
+ 'pro_page' => 'edit.php?post_type=bws-portfolio&page=portfolio-pro.php',
+ 'bws_license_plugin' => 'portfolio-pro/portfolio-pro.php',
+ 'link_key' => 'f047e20c92c972c398187a4f70240285',
+ 'link_pn' => '74',
+ ) );
+
+ $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'] );
+ } else {
+ $width = absint( get_option( $size . '_size_w' ) );
+ $height = absint( get_option( $size . '_size_h' ) );
+ }
+
+ if ( ! $width && ! $height ) {
+ $this->wp_image_sizes[] = array(
+ 'value' => $size,
+ 'name' => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ),
+ );
+ } else {
+ $this->wp_image_sizes[] = array(
+ 'value' => $size,
+ 'name' => ucwords( str_replace( array( '-', '_' ), ' ', $size ) ) . ' (' . $width . ' × ' . $height . ')',
+ 'width' => $width,
+ 'height' => $height
+ );
+ }
+ }
+ }
+
+ $this->cstmsrch_options = get_option( 'cstmsrch_options' );
+
+ $this->fields = array(
+ 'executor' => __( 'Executors', 'portfolio' ),
+ 'technologies' => __( 'Technologies', 'portfolio' ),
+ 'date' => __( 'Date of completion', 'portfolio' ),
+ 'link' => __( 'Link', 'portfolio' ),
+ 'shrdescription' => __( 'Short Description', 'portfolio' ),
+ 'description' => __( 'Description', 'portfolio' ),
+ 'svn' => __( 'SVN URL', '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
+ * @access public
+ * @param void
+ * @return array The action results
+ */
+ public function save_options() {
+
+ $this->options["custom_image_row_count"] = intval( $_POST['prtfl_custom_image_row_count'] );
+ if ( 1 > $this->options["custom_image_row_count"] )
+ $this->options["custom_image_row_count"] = 1;
+
+ $new_image_size_photo = esc_attr( $_POST['prtfl_image_size_photo'] );
+ $custom_image_size_w_photo = intval( $_POST['prtfl_custom_image_size_w_photo'] );
+ $custom_image_size_h_photo = intval( $_POST['prtfl_custom_image_size_h_photo'] );
+ $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;
+ } else {
+ foreach ( $custom_size_px_photo as $key => $value ) {
+ if ( $value != $this->options['custom_size_px']['portfolio-photo-thumb'][ $key ] ) {
+ $need_image_update = true;
+ break;
+ }
+ }
+ }
+ }
+ $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 = esc_attr( $_POST['prtfl_image_size_album'] );
+ $custom_image_size_w_album = intval( $_POST['prtfl_custom_image_size_w_album'] );
+ $custom_image_size_h_album = intval( $_POST['prtfl_custom_image_size_h_album'] );
+ $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;
+ } else {
+ foreach ( $custom_size_px_album as $key => $value ) {
+ if ( $value != $this->options['custom_size_px']['portfolio-thumb'][ $key ] ) {
+ $need_image_update = true;
+ break;
+ }
+ }
+ }
+ }
+
+ $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'] ) && $this->options['page_id_portfolio_template'] != intval( $_POST['prtfl_page_id_portfolio_template'] ) ) {
+ /* for rewrite */
+ $this->options["flush_rewrite_rules"] = 1;
+ $this->options['page_id_portfolio_template'] = intval( $_POST['prtfl_page_id_portfolio_template'] );
+ }
+
+ $this->options["order_by"] = esc_attr( $_POST['prtfl_order_by'] );
+ $this->options["order"] = esc_attr( $_POST['prtfl_order'] );
+
+ 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( $_REQUEST["prtfl_link_additional_field_for_non_registered"] ) ? 1 : 0;
+
+ foreach ( $this->fields as $field_key => $field_title ) {
+ $this->options[ $field_key . '_additional_field'] = isset( $_REQUEST['prtfl_' . $field_key . '_additional_field'] ) ? 1 : 0;
+ $this->options[ $field_key . '_text_field'] = stripslashes( esc_html( $_REQUEST['prtfl_' . $field_key . '_text_field'] ) );
+ }
+
+ $this->options['screenshot_text_field'] = stripslashes( esc_html( $_REQUEST['prtfl_screenshot_text_field'] ) );
+
+ $slug = strtolower( trim( stripslashes( esc_html( $_POST['prtfl_slug'] ) ) ) );
+ $slug = preg_replace( "/[^a-z0-9\s-]/", "", $slug );
+ $slug = trim( preg_replace( "/[\s-]+/", " ", $slug ) );
+ $slug = preg_replace( "/\s/", "-", $slug );
+ if ( $this->options["slug"] != $slug ) {
+ $this->options["flush_rewrite_rules"] = 1;
+ }
+ $this->options["slug"] = $slug;
+
+ /**
+ * rewriting post types name with unique one from default options
+ */
+ if ( ! empty( $_POST['prtfl_rename_post_type'] ) ) {
+ global $wpdb;
+ $wpdb->update(
+ $wpdb->prefix . 'posts',
+ 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'] ) {
+ $post_type_exist = true;
+ if ( $item['enabled'] != $is_enabled ) {
+ $this->cstmsrch_options['output_order'][ $key ]['enabled'] = $is_enabled;
+ $cstmsrch_options_update = true;
+ }
+ break;
+ }
+ }
+ if ( ! $post_type_exist ) {
+ $this->cstmsrch_options['output_order'][] = array(
+ 'name' => $this->options['post_type_name'],
+ 'type' => 'post_type',
+ '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
+ * @access public
+ * @param $save_results - array with error\message\notice
+ * @return void
+ */
+ public function display_custom_messages( $save_results ) { ?>
+
+ options['need_image_update'] ) ) { ?>
+
+
+ options['need_image_update']; ?>
+
+
+
+
+
+ help_phrase(); ?>
+
+
+ hide_pro_tabs ) { ?>
+
+
+ bws_pro_block_links(); ?>
+
+
+
+ hide_pro_tabs ) { ?>
+
+
+ bws_pro_block_links(); ?>
+
+
+
+ all_plugins ) {
+ if ( ! function_exists( 'get_plugins' ) ) {
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+ }
+ $this->all_plugins = get_plugins();
+ }
+ if ( $this->options['post_type_name'] != $this->default_options['post_type_name'] ) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ " />
+
+
+
+
+
+
+ all_plugins ) || array_key_exists( 'custom-search-pro/custom-search-pro.php', $this->all_plugins ) ) {
+ if ( ! is_plugin_active( 'custom-search-plugin/custom-search-plugin.php' ) && ! is_plugin_active( 'custom-search-pro/custom-search-pro.php' ) ) {
+ $disabled = ' disabled="disabled"';
+ $link = '' . __( 'Activate Now', 'portfolio' ) . ' ';
+ }
+ if ( isset( $this->cstmsrch_options['output_order'] ) ) {
+ foreach ( $this->cstmsrch_options['output_order'] as $key => $item ) {
+ if ( $item['name'] == $this->options['post_type_name'] && 'post_type' == $item['type'] ) {
+ if ( $item['enabled'] ) {
+ $checked = ' checked="checked"';
+ }
+ break;
+ }
+ }
+ } elseif ( ! empty( $this->cstmsrch_options['post_types'] ) && in_array( $this->options['post_type_name'], $this->cstmsrch_options['post_types'] ) ) {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ $disabled = ' disabled="disabled"';
+ $link = '' . __( 'Install Now', 'portfolio' ) . ' ';
+ } ?>
+ />
+
+
+
+
+
+