diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-content/plugins/portfolio/includes/class-prtfl-settings.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wp/wp-content/plugins/portfolio/includes/class-prtfl-settings.php Fri Sep 05 18:40:08 2025 +0200 @@ -0,0 +1,700 @@ + 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' ) ), + ); + + 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, + 'link_key' => 'f047e20c92c972c398187a4f70240285', + 'link_pn' => '74', + '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'] ); + } 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' ), + + ); + + 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 + * @return array The action results + */ + public function save_options() { + + $message = ''; + $notice = ''; + $error = ''; + + 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; + } else { + 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; + 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 = 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; + } else { + foreach ( $custom_size_px_album as $key => $value ) { + if ( absint( $value ) !== absint( $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'] ) && absint( $this->options['page_id_portfolio_template'] ) !== absint( $_POST['prtfl_page_id_portfolio_template'] ) ) { + /* for rewrite */ + $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'] ); + if ( false === $key ) { + $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; + } + } else { + $key = array_search( 'bws-portfolio', $sndr_options['automailout_new_post'] ); + if ( false !== $key ) { + 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'] ) ) { + 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 ( absint( $item['enabled'] ) !== absint( $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 array $save_results Array with error\message\notice. + */ + public function display_custom_messages( $save_results ) { ?> + + options['need_image_update'] ) ) { ?> +
+

+ options['need_image_update'] ); ?> + +

+
+ +

+ help_phrase(); ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 0, + 'selected' => esc_attr( $this->options['page_id_portfolio_template'] ), + 'name' => 'prtfl_page_id_portfolio_template', + 'show_option_none' => '...', + ) + ); + ?> +
+
+ change_permission_attr ); ?> type="number" name="prtfl_portfolio_custom_row_count" min="1" max="10000" value="options['custom_portfolio_row_count'] ); ?>" /> +
+
+ +
+
+ +
+
+ x px
+
+ +
+
+ x px +
+ hide_pro_tabs ) { ?> +
+
+ +
+ + + + + + + + + +
+ +
+
+ +
+
+ bws_pro_block_links(); ?> +
+ + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+ hide_pro_tabs ) { ?> +
+
+ +
+ + + + + + + + + +
+ +
+ +
+
+ bws_pro_block_links(); ?> +
+ + + + + + + + + + +
+ +
+ all_plugins ) ) { + if ( is_plugin_active( 'sender-pro/sender-pro.php' ) ) { + ?> +
+
+
+

+

+

+ +
+


+
+
+ +   +
+ +   +
+ + +
+ + +

+ help_phrase(); ?> +
+ + + + + +
+
+ fields as $field_key => $field_title ) { ?> + +
+ + + + + +
+
+ hide_pro_tabs ) { ?> +
+
+ +
+ + + + + +
+
+
+
+
+
+
+
+
+
+ bws_pro_block_links(); ?> +
+ + + + + + +
+ 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' ) ); ?> +
+ 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' ) . ''; + } + ?> + /> + + + + +
+

+ +

+
+ + +
+
+