plugin_basename, array( $this, 'add_go_pro_link_plugins_page' ) ); add_action( 'admin_menu', array( $this, 'pro_admin_menu' ), 12 ); add_action( 'admin_menu', array( $this, 'add_menu_if_portfolio_post_type_unregistered' ), 7 ); // Add Pro links to menu. add_action( 'admin_menu', array( $this, 'add_go_pro_url' ), 100 ); // register controls. add_action( 'init', array( $this, 'register_controls' ), 9 ); add_filter( 'vpf_extend_layouts', array( $this, 'add_default_layouts' ), 9 ); add_filter( 'vpf_extend_items_styles', array( $this, 'add_default_items_styles' ), 9 ); // ajax actions. add_action( 'wp_ajax_vp_find_oembed', array( $this, 'ajax_find_oembed' ) ); } /** * Add hight level Portfolio admin menu if portfolio post type unregistered. * * @return void */ public function add_menu_if_portfolio_post_type_unregistered() { if ( ! Visual_Portfolio_Custom_Post_Type::portfolio_post_type_is_registered() ) { add_menu_page( visual_portfolio()->plugin_name, visual_portfolio()->plugin_name, 'manage_options', 'visual-portfolio-settings', array( 'Visual_Portfolio_Settings', 'print_settings_page' ), 'dashicons-visual-portfolio', 25 ); } } /** * Enqueue styles and scripts */ public function admin_enqueue_scripts() { $data_init = array( 'nonce' => wp_create_nonce( 'vp-ajax-nonce' ), ); Visual_Portfolio_Assets::enqueue_script( 'visual-portfolio-admin', 'build/assets/admin/js/script' ); wp_localize_script( 'visual-portfolio-admin', 'VPAdminVariables', $data_init ); Visual_Portfolio_Assets::enqueue_style( 'visual-portfolio-admin', 'build/assets/admin/css/style' ); wp_style_add_data( 'visual-portfolio-admin', 'rtl', 'replace' ); wp_style_add_data( 'visual-portfolio-admin', 'suffix', '.min' ); } /** * Enqueue styles and scripts on saved layouts editor. */ public function saved_layouts_editor_enqueue_scripts() { if ( ! is_admin() ) { return; } if ( 'vp_lists' === get_post_type() ) { Visual_Portfolio_Assets::enqueue_script( 'visual-portfolio-saved-layouts', 'build/gutenberg/layouts-editor' ); Visual_Portfolio_Assets::enqueue_style( 'visual-portfolio-saved-layouts', 'build/gutenberg/style-layouts-editor' ); wp_style_add_data( 'visual-portfolio-saved-layouts', 'rtl', 'replace' ); wp_style_add_data( 'visual-portfolio-saved-layouts', 'suffix', '.min' ); $block_data = Visual_Portfolio_Get::get_options( array( 'id' => get_the_ID() ) ); $data_init = array( 'nonce' => wp_create_nonce( 'vp-ajax-nonce' ), ); wp_localize_script( 'visual-portfolio-saved-layouts', 'VPSavedLayoutVariables', array( 'nonce' => $data_init['nonce'], 'data' => $block_data, ) ); } } /** * Admin footer text. * * @param string $text The admin footer text. * * @return string */ public function admin_footer_text( $text ) { if ( ! function_exists( 'get_current_screen' ) ) { return $text; } $screen = get_current_screen(); // Determine if the current page being viewed is "Visual Portfolio" related. if ( isset( $screen->post_type ) && ( 'portfolio' === $screen->post_type || 'vp_lists' === $screen->post_type || 'vp_proofing' === $screen->post_type ) ) { $footer_text = esc_attr__( 'and', 'visual-portfolio' ) . ' ' . visual_portfolio()->plugin_name . ''; // Use RegExp to append "Visual Portfolio" after the element allowing translations to read correctly. return preg_replace( '/()/', '$1 ' . $footer_text, $text, 1 ); } return $text; } /** * Admin navigation. */ public function in_admin_header() { if ( ! function_exists( 'get_current_screen' ) ) { return; } $screen = get_current_screen(); $is_settings = ( isset( $screen->post_type ) && isset( $screen->id ) && 'toplevel_page_visual-portfolio-settings' === $screen->id ) ? true : false; // Determine if the current page being viewed is "Lazy Blocks" related. if ( ! isset( $screen->post_type ) || ( 'portfolio' !== $screen->post_type && 'vp_lists' !== $screen->post_type && 'vp_proofing' !== $screen->post_type && ! $is_settings ) || ( isset( $screen->is_block_editor ) && $screen->is_block_editor() ) ) { return; } global $submenu, $submenu_file, $plugin_page; $parent_slug = Visual_Portfolio_Custom_Post_Type::get_menu_slug(); $tabs = array(); // Generate array of navigation items. if ( isset( $submenu[ $parent_slug ] ) ) { foreach ( $submenu[ $parent_slug ] as $sub_item ) { // Check user can access page. if ( ! current_user_can( $sub_item[1] ) ) { continue; } // Ignore "Add New". if ( 'post-new.php?post_type=portfolio' === $sub_item[2] ) { continue; } // Define tab. $tab = array( 'text' => $sub_item[0], 'url' => $sub_item[2], ); // Convert submenu slug "test" to "$parent_slug&page=test". if ( ! strpos( $sub_item[2], '.php' ) && 0 !== strpos( $sub_item[2], 'https://' ) ) { $tab['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug ); } // Fixed Settings tab url if Portfolio Post Type disabled. if ( 'visual-portfolio-settings' === $parent_slug && 'visual-portfolio-settings' === $sub_item[2] ) { $tab['url'] = 'admin.php?page=' . $parent_slug; } // Detect active state. if ( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) { $tab['is_active'] = true; } $tabs[] = $tab; } } // Bail early if set to false. if ( false === $tabs ) { return; } ?>

plugin_name ); ?>

%s
', ! empty( $tab['is_active'] ) ? ' is-active' : '', esc_url( $tab['url'] ), wp_kses_post( $tab['text'] ) ); } ?>
'plugins_list' ) ) . '">' . esc_html__( 'Go Pro', 'visual-portfolio' ) . '', ) ); } /** * Get URL to main site with UTM tags. * * @param array $args - Arguments of link. * @return string */ public static function get_plugin_site_url( $args = array() ) { $args = array_merge( array( 'sub_path' => 'pricing', 'utm_source' => 'plugin', 'utm_medium' => 'admin_menu', 'utm_campaign' => 'go_pro', 'utm_content' => VISUAL_PORTFOLIO_VERSION, ), $args ); $url = 'https://visualportfolio.co/'; $first_flag = true; if ( isset( $args['sub_path'] ) && ! empty( $args['sub_path'] ) ) { $url .= $args['sub_path'] . '/'; } foreach ( $args as $key => $value ) { if ( 'sub_path' !== $key && ! empty( $value ) ) { $url .= ( $first_flag ? '?' : '&' ); $url .= $key . '=' . $value; $first_flag = false; } } return $url; } /** * Register the admin settings menu Pro link. * * @return void */ public function pro_admin_menu() { add_submenu_page( Visual_Portfolio_Custom_Post_Type::get_menu_slug(), '', ' ' . esc_html__( 'Go Pro', 'visual-portfolio' ), 'manage_options', 'visual_portfolio_go_pro' ); } /** * Add go pro links to admin menu. * * @return void */ public function add_go_pro_url() { global $submenu; $menu_slug = Visual_Portfolio_Custom_Post_Type::get_menu_slug(); if ( ! isset( $submenu[ $menu_slug ] ) ) { return; } $plugin_submenu = &$submenu[ $menu_slug ]; if ( is_array( $plugin_submenu ) && ! empty( $plugin_submenu ) ) { foreach ( $plugin_submenu as $key => $submenu_item ) { if ( 'visual_portfolio_go_pro' === $submenu_item[2] ) { $plugin_submenu[ $key ][2] = self::get_plugin_site_url( array( 'utm_medium' => 'admin_menu' ) ); } } } } /** * Add default layouts. * * @param array $layouts - layouts array. * * @return array */ public function add_default_layouts( $layouts ) { return array_merge( array( // Tiles. 'tiles' => array( 'title' => esc_html__( 'Tiles', 'visual-portfolio' ), 'icon' => '', 'controls' => array( /** * Tile type: * first parameter - is columns number * the next is item sizes * * Example: * 3|1,0.5|2,0.25| * 3 columns in row * First item 100% width and 50% height * Second item 200% width and 25% height */ array( 'type' => 'tiles_selector', 'label' => esc_html__( 'Tiles Preview', 'visual-portfolio' ), 'name' => 'type', 'default' => '3|1,1|', 'reload_iframe' => false, 'options' => array_merge( array( array( 'value' => '1|1,0.5|', ), array( 'value' => '2|1,1|', ), array( 'value' => '2|1,0.8|', ), array( 'value' => '2|1,1.34|', ), array( 'value' => '2|1,1.2|1,1.2|1,0.67|1,0.67|', ), array( 'value' => '2|1,1.2|1,0.67|1,1.2|1,0.67|', ), array( 'value' => '2|1,0.67|1,1|1,1|1,1|1,1|1,0.67|', ), array( 'value' => '3|1,1|', ), array( 'value' => '3|1,0.8|', ), array( 'value' => '3|1,1.3|', ), array( 'value' => '3|1,1|1,1|1,1|1,1.3|1,1.3|1,1.3|', ), array( 'value' => '3|1,1|1,1|1,2|1,1|1,1|1,1|1,1|1,1|', ), array( 'value' => '3|1,2|1,1|1,1|1,1|1,1|1,1|1,1|1,1|', ), array( 'value' => '3|1,1|1,2|1,1|1,1|1,1|1,1|1,1|1,1|', ), array( 'value' => '3|1,1|1,2|1,1|1,1|1,1|1,1|2,0.5|', ), array( 'value' => '3|1,0.8|1,1.6|1,0.8|1,0.8|1,1.6|1,0.8|1,0.8|1,0.8|1,0.8|1,0.8|', ), array( 'value' => '3|1,0.8|1,1.6|1,0.8|1,0.8|1,1.6|1,1.6|1,0.8|1,0.8|1,0.8|', ), array( 'value' => '3|1,0.8|1,0.8|1,1.6|1,0.8|1,0.8|1,1.6|1,1.6|1,0.8|1,0.8|', ), array( 'value' => '3|1,0.8|1,0.8|1,1.6|1,0.8|1,0.8|1,0.8|1,1.6|1,1.6|1,0.8|', ), array( 'value' => '3|1,1|2,1|1,1|2,0.5|1,1|', ), array( 'value' => '3|1,1|2,1|1,1|1,1|1,1|1,1|2,0.5|1,1|', ), array( 'value' => '3|1,2|2,0.5|1,1|1,2|2,0.5|', ), array( 'value' => '4|1,1|', ), array( 'value' => '4|1,1|1,1.34|1,1|1,1.34|1,1.34|1,1.34|1,1|1,1|', ), array( 'value' => '4|1,0.8|1,1|1,0.8|1,1|1,1|1,1|1,0.8|1,0.8|', ), array( 'value' => '4|1,1|1,1|2,1|1,1|1,1|2,1|1,1|1,1|1,1|1,1|', ), array( 'value' => '4|2,1|2,0.5|2,0.5|2,0.5|2,1|2,0.5|', ), ), // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( array( 'value' => '1|1,0.5|', ), array( 'value' => '2|1,1|', ), ) */ apply_filters( 'vpf_extend_tiles', array() ) ), ), ), ), // Masonry. 'masonry' => array( 'title' => esc_html__( 'Masonry', 'visual-portfolio' ), 'icon' => '', 'controls' => array( array( 'type' => 'number', 'label' => esc_html__( 'Columns', 'visual-portfolio' ), 'name' => 'columns', 'min' => 1, 'max' => 5, 'default' => 3, 'reload_iframe' => false, ), array( 'type' => 'aspect_ratio', 'label' => esc_html__( 'Images Aspect Ratio', 'visual-portfolio' ), 'name' => 'images_aspect_ratio', 'default' => '', 'reload_iframe' => false, 'style' => array( array( 'element' => '.vp-portfolio__item-wrap .vp-portfolio__item-img-wrap::before', 'property' => 'padding-top', ), ), ), ), ), // Grid. 'grid' => array( 'title' => esc_html__( 'Grid', 'visual-portfolio' ), 'icon' => '', 'controls' => array( array( 'type' => 'number', 'label' => esc_html__( 'Columns', 'visual-portfolio' ), 'name' => 'columns', 'min' => 1, 'max' => 5, 'default' => 3, 'reload_iframe' => false, ), array( 'type' => 'aspect_ratio', 'label' => esc_html__( 'Images Aspect Ratio', 'visual-portfolio' ), 'name' => 'images_aspect_ratio', 'default' => '', 'reload_iframe' => false, 'style' => array( array( 'element' => '.vp-portfolio__item-wrap .vp-portfolio__item-img-wrap::before', 'property' => 'padding-top', ), ), ), ), ), // Justified. 'justified' => array( 'title' => esc_html__( 'Justified', 'visual-portfolio' ), 'icon' => '', 'controls' => array( array( 'type' => 'range', 'label' => esc_html__( 'Row Height', 'visual-portfolio' ), 'name' => 'row_height', 'group' => 'justified_row_height', 'min' => 100, 'max' => 1000, 'default' => 200, 'reload_iframe' => false, ), array( 'type' => 'range', 'label' => esc_html__( 'Row Height Tolerance', 'visual-portfolio' ), 'name' => 'row_height_tolerance', 'group' => 'justified_row_height', 'min' => 0, 'max' => 1, 'step' => 0.05, 'default' => 0.25, 'reload_iframe' => false, ), array( 'type' => 'range', 'label' => esc_html__( 'Max Rows Count', 'visual-portfolio' ), 'description' => esc_html__( 'Limit the number of rows to display. 0 means - unlimited.', 'visual-portfolio' ), 'name' => 'max_rows_count', 'min' => 0, 'max' => 50, 'step' => 1, 'default' => 0, 'reload_iframe' => false, ), array( 'type' => 'select', 'label' => esc_html__( 'Last Row Align', 'visual-portfolio' ), 'name' => 'last_row', 'default' => 'left', 'reload_iframe' => false, 'options' => array( 'left' => esc_html__( 'Left', 'visual-portfolio' ), 'center' => esc_html__( 'Center', 'visual-portfolio' ), 'right' => esc_html__( 'Right', 'visual-portfolio' ), 'hide' => esc_html__( 'Hide', 'visual-portfolio' ), ), ), ), ), // Slider. 'slider' => array( 'title' => esc_html__( 'Slider', 'visual-portfolio' ), 'icon' => '', 'controls' => array( array( 'type' => 'icons_selector', 'label' => esc_html__( 'Effect', 'visual-portfolio' ), 'name' => 'effect', 'default' => 'slide', 'reload_iframe' => false, 'options' => array( 'slide' => array( 'value' => 'slide', 'title' => esc_html__( 'Slide', 'visual-portfolio' ), 'icon' => '', ), 'coverflow' => array( 'value' => 'coverflow', 'title' => esc_html__( 'Coverflow', 'visual-portfolio' ), 'icon' => '', ), 'fade' => array( 'value' => 'fade', 'title' => esc_html__( 'Fade', 'visual-portfolio' ), 'icon' => '', ), ), ), array( 'type' => 'range', 'label' => esc_html__( 'Speed (in Seconds)', 'visual-portfolio' ), 'name' => 'speed', 'min' => 0, 'max' => 5, 'step' => 0.1, 'default' => 0.3, 'reload_iframe' => false, ), array( 'type' => 'range', 'label' => esc_html__( 'Autoplay (in Seconds)', 'visual-portfolio' ), 'name' => 'autoplay', 'min' => 0, 'max' => 60, 'step' => 0.2, 'default' => 6, 'reload_iframe' => false, ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Pause on Mouse Over', 'visual-portfolio' ), 'name' => 'autoplay_hover_pause', 'default' => false, 'reload_iframe' => false, 'condition' => array( array( 'control' => 'autoplay', 'operator' => '>', 'value' => 0, ), ), ), array( 'type' => 'radio', 'label' => esc_html__( 'Items Height', 'visual-portfolio' ), 'name' => 'items_height_type', 'group' => 'slider_items_height', 'default' => 'dynamic', 'options' => array( 'auto' => esc_html__( 'Auto', 'visual-portfolio' ), 'static' => esc_html__( 'Static (px)', 'visual-portfolio' ), 'dynamic' => esc_html__( 'Dynamic (%)', 'visual-portfolio' ), ), ), array( 'type' => 'number', 'name' => 'items_height_static', 'group' => 'slider_items_height', 'min' => 30, 'max' => 800, 'default' => 300, 'condition' => array( array( 'control' => 'items_height_type', 'operator' => '==', 'value' => 'static', ), ), ), array( 'type' => 'number', 'name' => 'items_height_dynamic', 'group' => 'slider_items_height', 'min' => 10, 'max' => 300, 'default' => 80, 'condition' => array( array( 'control' => 'items_height_type', 'operator' => '==', 'value' => 'dynamic', ), ), ), array( 'type' => 'text', 'label' => esc_html__( 'Items Minimal Height', 'visual-portfolio' ), 'placeholder' => esc_attr__( '300px, 80vh', 'visual-portfolio' ), 'description' => esc_html__( 'Values with `vh` units will not be visible in preview.', 'visual-portfolio' ), 'name' => 'items_min_height', 'group' => 'slider_items_height', 'default' => '', 'condition' => array( array( 'control' => 'items_height_type', 'operator' => '!==', 'value' => 'auto', ), ), ), array( 'type' => 'radio', 'label' => esc_html__( 'Slides Per View', 'visual-portfolio' ), 'name' => 'slides_per_view_type', 'group' => 'slider_slides_per_view', 'default' => 'custom', 'options' => array( 'auto' => esc_html__( 'Auto', 'visual-portfolio' ), 'custom' => esc_html__( 'Custom', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'effect', 'operator' => '!=', 'value' => 'fade', ), ), ), array( 'type' => 'number', 'name' => 'slides_per_view_custom', 'group' => 'slider_slides_per_view', 'min' => 1, 'max' => 6, 'default' => 3, 'condition' => array( array( 'control' => 'effect', 'operator' => '!=', 'value' => 'fade', ), array( 'control' => 'slides_per_view_type', 'operator' => '==', 'value' => 'custom', ), ), ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Centered Slides', 'visual-portfolio' ), 'name' => 'centered_slides', 'default' => true, 'reload_iframe' => false, 'condition' => array( array( 'control' => 'effect', 'operator' => '!=', 'value' => 'fade', ), ), ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Loop', 'visual-portfolio' ), 'name' => 'loop', 'default' => false, 'reload_iframe' => false, ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Free Scroll', 'visual-portfolio' ), 'name' => 'free_mode', 'group' => 'slider_free_mode', 'default' => false, 'reload_iframe' => false, ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Free Scroll Sticky', 'visual-portfolio' ), 'name' => 'free_mode_sticky', 'group' => 'slider_free_mode', 'default' => false, 'reload_iframe' => false, 'condition' => array( array( 'control' => 'free_mode', ), ), ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Display Arrows', 'visual-portfolio' ), 'name' => 'arrows', 'default' => true, ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Display Bullets', 'visual-portfolio' ), 'name' => 'bullets', 'group' => 'slider_bullets', 'default' => false, ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Dynamic Bullets', 'visual-portfolio' ), 'name' => 'bullets_dynamic', 'group' => 'slider_bullets', 'default' => false, 'reload_iframe' => false, 'condition' => array( array( 'control' => 'bullets', ), ), ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Mousewheel Control', 'visual-portfolio' ), 'name' => 'mousewheel', 'default' => false, ), array( 'type' => 'checkbox', 'alongside' => esc_html__( 'Display Thumbnails', 'visual-portfolio' ), 'name' => 'thumbnails', 'group' => 'slider_thumbnails', 'default' => false, ), array( 'type' => 'range', 'label' => esc_html__( 'Thumbnails Gap', 'visual-portfolio' ), 'name' => 'thumbnails_gap', 'group' => 'slider_thumbnails', 'default' => 15, 'min' => 0, 'max' => 150, 'condition' => array( array( 'control' => 'thumbnails', ), ), ), array( 'type' => 'radio', 'label' => esc_html__( 'Thumbnails Height', 'visual-portfolio' ), 'name' => 'thumbnails_height_type', 'group' => 'slider_thumbnails', 'default' => 'static', 'options' => array( 'auto' => esc_html__( 'Auto', 'visual-portfolio' ), 'static' => esc_html__( 'Static (px)', 'visual-portfolio' ), 'dynamic' => esc_html__( 'Dynamic (%)', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'thumbnails', ), ), ), array( 'type' => 'number', 'name' => 'thumbnails_height_static', 'group' => 'slider_thumbnails', 'min' => 10, 'max' => 400, 'default' => 100, 'condition' => array( array( 'control' => 'thumbnails', ), array( 'control' => 'thumbnails_height_type', 'operator' => '==', 'value' => 'static', ), ), ), array( 'type' => 'number', 'name' => 'thumbnails_height_dynamic', 'group' => 'slider_thumbnails', 'min' => 10, 'max' => 200, 'default' => 30, 'condition' => array( array( 'control' => 'thumbnails', ), array( 'control' => 'thumbnails_height_type', 'operator' => '==', 'value' => 'dynamic', ), ), ), array( 'type' => 'radio', 'label' => esc_html__( 'Thumbnails Per View', 'visual-portfolio' ), 'name' => 'thumbnails_per_view_type', 'group' => 'slider_thumbnails', 'default' => 'custom', 'options' => array( 'auto' => esc_html__( 'Auto', 'visual-portfolio' ), 'custom' => esc_html__( 'Custom', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'thumbnails', ), ), ), array( 'type' => 'number', 'name' => 'thumbnails_per_view_custom', 'group' => 'slider_thumbnails', 'min' => 1, 'max' => 14, 'default' => 8, 'condition' => array( array( 'control' => 'thumbnails', ), array( 'control' => 'thumbnails_per_view_type', 'operator' => '==', 'value' => 'custom', ), ), ), ), ), ), $layouts ); } /** * Add default items styles. * * @param array $items_styles - items styles array. * * @return array */ public function add_default_items_styles( $items_styles ) { return array_merge( array( // Classic. 'default' => array( 'title' => esc_html__( 'Classic', 'visual-portfolio' ), 'icon' => '', 'image_preview_wizard' => visual_portfolio()->plugin_url . '/assets/admin/images/items-style-preview-classic.png', 'builtin_controls' => array( 'image' => array( 'border_radius' => true, 'transform' => true, // Pro. 'css_filter' => true, // Pro. ), 'overlay' => array( 'states' => true, 'text_align' => false, // Elements. 'elements' => array( 'icons' => true, ), // Colors. 'colors' => array( 'background' => true, 'text' => true, 'links' => false, 'mix_blend_mode' => true, // Pro. ), // Dimensions Pro. 'dimensions' => array( 'border_radius' => true, 'margin' => true, ), ), 'caption' => array( 'states' => false, 'text_align' => 'horizontal', // Elements. 'elements' => array( 'title' => true, 'categories' => true, 'date' => true, 'author' => true, 'comments_count' => true, 'views_count' => true, 'reading_time' => true, 'excerpt' => true, 'read_more' => true, ), // Colors. 'colors' => array( 'background' => false, 'text' => true, 'links' => true, ), // Typography Pro. 'typography' => array( 'title' => true, 'category' => true, 'meta' => true, 'description' => true, 'button' => true, ), // Dimensions Pro. 'dimensions' => array( 'padding' => true, 'items_gap' => true, ), ), ), 'controls' => array( // Nothing here yet, all options are in builtin controls. ), ), // Fade. 'fade' => array( 'title' => esc_html__( 'Fade', 'visual-portfolio' ), 'icon' => '', 'image_preview_wizard' => visual_portfolio()->plugin_url . '/assets/admin/images/items-style-preview-fade.png', 'builtin_controls' => array( 'image' => array( 'border_radius' => true, 'transform' => true, // Pro. 'css_filter' => true, // Pro. ), 'overlay' => array( 'states' => true, // All available align values: 'horizontal'|'vertical'|'box'. 'text_align' => 'box', 'under_image' => true, // Pro. // Elements. 'elements' => array( 'title' => true, 'categories' => true, 'date' => true, 'author' => true, 'comments_count' => true, 'views_count' => true, 'reading_time' => true, 'excerpt' => true, 'read_more' => false, 'icons' => true, ), // Colors. 'colors' => array( 'background' => true, 'text' => true, 'links' => false, 'mix_blend_mode' => true, // Pro. ), // Typography Pro. 'typography' => array( 'title' => true, 'category' => true, 'meta' => true, 'description' => true, ), // Dimensions Pro. 'dimensions' => array( 'border_radius' => true, 'padding' => true, 'margin' => true, 'items_gap' => true, ), ), 'caption' => false, ), 'controls' => array( // Nothing here yet, all options are in builtin controls. ), ), // Fly. 'fly' => array( 'title' => esc_html__( 'Fly', 'visual-portfolio' ), 'icon' => '', 'image_preview_wizard' => visual_portfolio()->plugin_url . '/assets/admin/images/items-style-preview-fly.png', 'builtin_controls' => array( 'image' => array( 'border_radius' => true, 'transform' => true, // Pro. 'css_filter' => true, // Pro. ), 'overlay' => array( 'states' => true, // All available align values: 'horizontal'|'vertical'|'box'. 'text_align' => 'box', 'under_image' => true, // Pro. // Elements. 'elements' => array( 'title' => true, 'categories' => true, 'date' => true, 'author' => true, 'comments_count' => true, 'views_count' => true, 'reading_time' => true, 'excerpt' => true, 'read_more' => false, 'icons' => true, ), // Colors. 'colors' => array( 'background' => true, 'text' => true, 'links' => false, 'mix_blend_mode' => true, // Pro. ), // Typography Pro. 'typography' => array( 'title' => true, 'category' => true, 'meta' => true, 'description' => true, ), // Dimensions Pro. 'dimensions' => array( 'border_radius' => true, 'padding' => true, 'margin' => true, 'items_gap' => true, ), ), 'caption' => false, ), 'controls' => array( // Nothing here yet, all options are in builtin controls. ), ), // Emerge. 'emerge' => array( 'title' => esc_html__( 'Emerge', 'visual-portfolio' ), 'icon' => '', 'image_preview_wizard' => visual_portfolio()->plugin_url . '/assets/admin/images/items-style-preview-emerge.png', 'builtin_controls' => array( 'image' => array( 'border_radius' => true, 'transform' => true, // Pro. 'css_filter' => true, // Pro. ), 'overlay' => array( 'states' => true, // Colors. 'colors' => array( 'background' => true, 'text' => false, 'links' => false, 'mix_blend_mode' => true, // Pro. ), // Dimensions Pro. 'dimensions' => array( 'border_radius' => true, 'margin' => true, ), ), 'caption' => array( 'states' => true, // All available align values: 'horizontal'|'vertical'|'box'. 'text_align' => 'horizontal', 'under_image' => true, // Pro. // Elements. 'elements' => array( 'title' => true, 'categories' => true, 'date' => true, 'author' => true, 'comments_count' => true, 'views_count' => true, 'reading_time' => true, 'excerpt' => true, 'read_more' => false, 'icons' => false, ), // Colors. 'colors' => array( 'background' => true, 'text' => true, 'links' => true, 'mix_blend_mode' => true, // Pro. ), // Typography Pro. 'typography' => array( 'title' => true, 'category' => true, 'meta' => true, 'description' => true, ), // Dimensions Pro. 'dimensions' => array( 'padding' => true, 'items_gap' => true, ), ), ), 'controls' => array( // Nothing here yet, all options are in builtin controls. ), ), ), $items_styles ); } /** * Register control fields for the metaboxes. */ public function register_controls() { do_action( 'vpf_before_register_controls' ); /** * Categories. */ Visual_Portfolio_Controls::register_categories( array( 'content-source' => array( 'title' => esc_html__( 'Content Source', 'visual-portfolio' ), 'is_opened' => true, ), 'content-source-post-based' => array( 'title' => esc_html__( 'Posts Settings', 'visual-portfolio' ), 'is_opened' => true, 'icon' => '', ), 'content-source-images' => array( 'title' => esc_html__( 'Images Settings', 'visual-portfolio' ), 'is_opened' => true, 'icon' => '', ), 'content-source-social-stream' => array( 'title' => esc_html__( 'Social Stream Settings', 'visual-portfolio' ), 'is_opened' => true, 'icon' => '', ), 'content-source-general' => array( 'title' => esc_html__( 'General Settings', 'visual-portfolio' ), 'is_opened' => true, 'icon' => '', ), 'layout-elements' => array( 'title' => esc_html__( 'Layout', 'visual-portfolio' ), 'is_opened' => false, 'icon' => '', ), 'items-style' => array( 'title' => esc_html__( 'Skin', 'visual-portfolio' ), 'is_opened' => false, 'icon' => '', ), 'items-click-action' => array( 'title' => esc_html__( 'Click Action', 'visual-portfolio' ), 'is_opened' => false, 'icon' => '', ), 'content-protection' => array( 'title' => esc_html__( 'Protection', 'visual-portfolio' ), 'is_opened' => false, 'icon' => '', ), 'custom_css' => array( 'title' => esc_html__( 'Custom CSS', 'visual-portfolio' ), 'is_opened' => false, 'icon' => '', ), ) ); /** * Enabled preview for gutenberg block. */ Visual_Portfolio_Controls::register( array( 'type' => 'hidden', 'name' => 'preview_image_example', 'default' => '', ) ); /** * Enabled setup wizard. */ Visual_Portfolio_Controls::register( array( 'type' => 'hidden', 'name' => 'setup_wizard', 'default' => '', ) ); /** * Content Source */ Visual_Portfolio_Controls::register( array( 'category' => 'content-source', 'type' => 'icons_selector', 'name' => 'content_source', 'setup_wizard' => true, 'default' => '', 'options' => array( 'post-based' => array( 'value' => 'post-based', 'title' => esc_html__( 'Posts', 'visual-portfolio' ), 'icon' => '', 'icon_wizard' => '', ), 'images' => array( 'value' => 'images', 'title' => esc_html__( 'Images', 'visual-portfolio' ), 'icon' => '', 'icon_wizard' => '', ), 'social-stream' => array( 'value' => 'social-stream', 'title' => esc_html__( 'Social', 'visual-portfolio' ), 'icon' => '', 'icon_wizard' => '', ), ), ) ); /** * Content Source Posts */ Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'icons_selector', 'name' => 'posts_source', 'default' => 'portfolio', 'collapse_rows' => 2, 'value_callback' => array( $this, 'find_post_types_options' ), ) ); $allowed_protocols = array( 'a' => array( 'href' => array(), 'target' => array(), ), ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'textarea', 'label' => esc_html__( 'Custom Query', 'visual-portfolio' ), // translators: %1$s - escaped url. 'description' => sprintf( wp_kses( __( 'Build custom query according to WordPress Codex. See example here %1$s.', 'visual-portfolio' ), $allowed_protocols ), esc_url( 'https://visualportfolio.co/docs/portfolio-layouts/content-source/post-based/#custom-query' ) ), 'name' => 'posts_custom_query', 'default' => '', 'cols' => 30, 'rows' => 3, 'condition' => array( array( 'control' => 'posts_source', 'value' => 'custom_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'select', 'label' => esc_html__( 'Post Types', 'visual-portfolio' ), 'name' => 'post_types_set', 'default' => array( 'post' ), 'value_callback' => array( $this, 'find_posts_types_select_control' ), 'multiple' => true, 'condition' => array( array( 'control' => 'posts_source', 'value' => 'post_types_set', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'select', 'label' => esc_html__( 'Specific Posts', 'visual-portfolio' ), 'name' => 'posts_ids', 'default' => array(), 'value_callback' => array( $this, 'find_posts_select_control' ), 'searchable' => true, 'multiple' => true, 'condition' => array( array( 'control' => 'posts_source', 'value' => 'ids', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'select', 'label' => esc_html__( 'Excluded Posts', 'visual-portfolio' ), 'name' => 'posts_excluded_ids', 'default' => array(), 'value_callback' => array( $this, 'find_posts_select_control' ), 'searchable' => true, 'multiple' => true, 'condition' => array( array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'ids', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'select', 'label' => esc_html__( 'Taxonomies', 'visual-portfolio' ), 'name' => 'posts_taxonomies', 'group' => 'posts_taxonomies', 'default' => array(), 'value_callback' => array( $this, 'find_taxonomies_select_control' ), 'searchable' => true, 'multiple' => true, 'condition' => array( array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'ids', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'radio', 'label' => esc_html__( 'Taxonomies Relation', 'visual-portfolio' ), 'name' => 'posts_taxonomies_relation', 'group' => 'posts_taxonomies', 'default' => 'or', 'options' => array( 'or' => esc_html__( 'OR', 'visual-portfolio' ), 'and' => esc_html__( 'AND', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'ids', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'select', 'label' => esc_html__( 'Order by', 'visual-portfolio' ), 'name' => 'posts_order_by', 'group' => 'posts_order', 'default' => 'post_date', 'options' => array( 'post_date' => esc_html__( 'Date', 'visual-portfolio' ), 'title' => esc_html__( 'Title', 'visual-portfolio' ), 'id' => esc_html__( 'ID', 'visual-portfolio' ), 'comment_count' => esc_html__( 'Comments Count', 'visual-portfolio' ), 'modified' => esc_html__( 'Modified', 'visual-portfolio' ), 'menu_order' => esc_html__( 'Menu Order', 'visual-portfolio' ), 'post__in' => esc_html__( 'Manual Selection', 'visual-portfolio' ), 'rand' => esc_html__( 'Random', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'notice', // translators: %1$s - url. // translators: %2$s - link text. 'description' => wp_kses_post( sprintf( __( 'Menu Order is typically used in combination with one of these plugins: %2$s', 'visual-portfolio' ), 'https://wordpress.org/plugins/search/post+order/', 'Post Order Plugins' ) ), 'name' => 'posts_order_direction_notice', 'group' => 'posts_order', 'condition' => array( array( 'control' => 'posts_order_by', 'operator' => '===', 'value' => 'menu_order', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'radio', 'label' => esc_html__( 'Order Direction', 'visual-portfolio' ), 'name' => 'posts_order_direction', 'group' => 'posts_order', 'default' => 'desc', 'options' => array( 'asc' => esc_html__( 'ASC', 'visual-portfolio' ), 'desc' => esc_html__( 'DESC', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'checkbox', 'alongside' => esc_html__( 'Avoid Duplicates', 'visual-portfolio' ), 'description' => esc_html__( 'Enable to avoid duplicate posts from showing up. This only affects the frontend', 'visual-portfolio' ), 'name' => 'posts_avoid_duplicate_posts', 'default' => false, 'reload_iframe' => false, ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'range', 'label' => esc_html__( 'Offset', 'visual-portfolio' ), 'description' => esc_html__( 'Use this setting to skip over posts (e.g. `2` to skip over 2 posts)', 'visual-portfolio' ), 'name' => 'posts_offset', 'min' => 0, 'max' => 100, 'condition' => array( array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'ids', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'custom_query', ), array( 'control' => 'posts_source', 'operator' => '!=', 'value' => 'current_query', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-post-based', 'type' => 'pro_note', 'name' => 'additional_query_settings_pro', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => esc_html__( 'Additional query settings, such as:', 'visual-portfolio' ) . ' ', ) ); /** * Content Source Images */ Visual_Portfolio_Controls::register( array( 'category' => 'content-source-images', 'type' => 'gallery', 'name' => 'images', 'wpml' => true, 'setup_wizard' => true, 'focal_point' => true, 'image_controls' => array( 'title' => array( 'type' => 'text', 'label' => esc_html__( 'Title', 'visual-portfolio' ), ), 'description' => array( 'type' => 'textarea', 'label' => esc_html__( 'Description', 'visual-portfolio' ), ), 'categories' => array( 'type' => 'select', 'label' => esc_html__( 'Categories', 'visual-portfolio' ), 'multiple' => true, 'creatable' => true, ), 'format' => array( 'type' => 'select', 'label' => esc_html__( 'Format', 'visual-portfolio' ), 'default' => 'standard', 'options' => array( 'standard' => esc_html__( 'Standard', 'visual-portfolio' ), 'video' => esc_html__( 'Video', 'visual-portfolio' ), ), ), 'video_url' => array( 'type' => 'text', 'label' => esc_html__( 'Video URL', 'visual-portfolio' ), 'placeholder' => esc_html__( 'https://...', 'visual-portfolio' ), 'description' => esc_html__( 'Full list of supported links', 'visual-portfolio' ) . ' ' . esc_html__( 'see here', 'visual-portfolio' ) . '', 'condition' => array( array( 'control' => 'SELF.format', 'value' => 'video', ), ), ), 'url' => array( 'type' => 'text', 'label' => esc_html__( 'URL', 'visual-portfolio' ), 'description' => esc_html__( 'By default used full image url, you can use custom one', 'visual-portfolio' ), 'placeholder' => esc_html__( 'https://...', 'visual-portfolio' ), ), 'author' => array( 'type' => 'text', 'label' => esc_html__( 'Author Name', 'visual-portfolio' ), 'default' => '', ), 'author_url' => array( 'type' => 'text', 'label' => esc_html__( 'Author URL', 'visual-portfolio' ), 'default' => '', ), 'image_settings_pro_note' => array( 'type' => 'pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '', ), ), 'default' => array( /** * Array items: * id - image id. * title - image title. * description - image description. * categories - categories array. * format - image format [standard,video]. * video_url - video url. */ ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-images', 'type' => 'select', 'label' => esc_html__( 'Items Title Source', 'visual-portfolio' ), 'name' => 'images_titles_source', 'group' => 'images_titles_source', 'default' => 'custom', 'options' => array( 'none' => esc_html__( 'None', 'visual-portfolio' ), 'custom' => esc_html__( 'Custom', 'visual-portfolio' ), 'title' => esc_html__( 'Image Title', 'visual-portfolio' ), 'caption' => esc_html__( 'Image Caption', 'visual-portfolio' ), 'alt' => esc_html__( 'Image Alt', 'visual-portfolio' ), 'description' => esc_html__( 'Image Description', 'visual-portfolio' ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-images', 'type' => 'select', 'label' => esc_html__( 'Items Description Source', 'visual-portfolio' ), 'name' => 'images_descriptions_source', 'group' => 'images_titles_source', 'default' => 'custom', 'options' => array( 'none' => esc_html__( 'None', 'visual-portfolio' ), 'custom' => esc_html__( 'Custom', 'visual-portfolio' ), 'title' => esc_html__( 'Image Title', 'visual-portfolio' ), 'caption' => esc_html__( 'Image Caption', 'visual-portfolio' ), 'alt' => esc_html__( 'Image Alt', 'visual-portfolio' ), 'description' => esc_html__( 'Image Description', 'visual-portfolio' ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-images', 'type' => 'select', 'label' => esc_html__( 'Order by', 'visual-portfolio' ), 'name' => 'images_order_by', 'group' => 'images_order', 'default' => 'default', 'options' => array( 'default' => esc_html__( 'Default', 'visual-portfolio' ), 'date' => esc_html__( 'Uploaded', 'visual-portfolio' ), 'title' => esc_html__( 'Title', 'visual-portfolio' ), 'rand' => esc_html__( 'Random', 'visual-portfolio' ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-images', 'type' => 'radio', 'label' => esc_html__( 'Order Direction', 'visual-portfolio' ), 'name' => 'images_order_direction', 'group' => 'images_order', 'default' => 'asc', 'options' => array( 'asc' => esc_html__( 'ASC', 'visual-portfolio' ), 'desc' => esc_html__( 'DESC', 'visual-portfolio' ), ), ) ); /** * Content Source Protection. */ Visual_Portfolio_Controls::register( array( 'category' => 'content-protection', 'type' => 'pro_note', 'name' => 'protection_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '

' . esc_html__( 'Protect your works using watermarks, password, and age gate', 'visual-portfolio' ) . '

', 'condition' => array( array( 'control' => 'content_source', 'operator' => '!==', 'value' => 'social-stream', ), ), ) ); /** * Content Source Social Stream. */ Visual_Portfolio_Controls::register( array( 'category' => 'content-source-social-stream', 'type' => 'pro_note', 'name' => 'social_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '

' . esc_html__( 'Display social feeds such as Instagram, Youtube, Flickr, Twitter, etc...', 'visual-portfolio' ) . '

', 'setup_wizard' => true, ) ); /** * Content Source General Settings. */ Visual_Portfolio_Controls::register( array( 'category' => 'content-source-general', 'type' => 'number', 'label' => esc_html__( 'Items Per Page', 'visual-portfolio' ), 'name' => 'items_count', 'default' => 6, 'min' => 1, 'condition' => array( array( array( 'control' => 'content_source', 'operator' => '!==', 'value' => 'post-based', ), // AND. array( 'control' => 'posts_source', 'operator' => '!==', 'value' => 'current_query', ), ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-general', 'type' => 'buttons', 'label' => esc_html__( 'No Items Action', 'visual-portfolio' ), 'name' => 'no_items_action', 'group' => 'no_items_action', 'default' => 'notice', 'options' => array( 'notice' => esc_html__( 'Notice', 'visual-portfolio' ), 'hide' => esc_html__( 'Hide', 'visual-portfolio' ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-general', 'type' => 'textarea', 'placeholder' => esc_html__( 'Notice', 'visual-portfolio' ), 'name' => 'no_items_notice', 'group' => 'no_items_action', 'default' => esc_html__( 'No items were found matching your selection.', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'no_items_action', 'operator' => '===', 'value' => 'notice', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-general', 'type' => 'html', 'description' => esc_html__( 'Note: you will see the notice in the preview. Block will be hidden in the site frontend.', 'visual-portfolio' ), 'name' => 'no_items_action_hide_info', 'group' => 'no_items_action', 'condition' => array( array( 'control' => 'no_items_action', 'operator' => '===', 'value' => 'hide', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'content-source-general', 'type' => 'checkbox', 'alongside' => esc_html__( 'Stretch', 'visual-portfolio' ), 'name' => 'stretch', 'default' => false, 'reload_iframe' => false, 'description' => esc_attr__( 'Break container and display it wide. This option helpful for 3rd-party page builders, in the Gutenberg themes you can use the built in Wide and Fullwidth features.', 'visual-portfolio' ), ) ); /** * Layouts. */ $layouts = Visual_Portfolio_Get::get_all_layouts(); // Layouts selector. $layouts_selector = array(); foreach ( $layouts as $name => $layout ) { $layouts_selector[ $name ] = array( 'value' => $name, 'title' => $layout['title'], 'icon' => isset( $layout['icon'] ) ? $layout['icon'] : '', ); } Visual_Portfolio_Controls::register( array( 'category' => 'layouts', 'type' => 'icons_selector', 'name' => 'layout', 'default' => 'tiles', 'options' => $layouts_selector, ) ); // layouts options. foreach ( $layouts as $name => $layout ) { if ( ! isset( $layout['controls'] ) ) { continue; } foreach ( $layout['controls'] as $field ) { $field['category'] = 'layouts'; $field['name'] = $name . '_' . $field['name']; // condition names prefix fix. if ( isset( $field['condition'] ) ) { foreach ( $field['condition'] as $k => $cond ) { if ( isset( $cond['control'] ) ) { if ( strpos( $cond['control'], 'GLOBAL_' ) === 0 ) { $field['condition'][ $k ]['control'] = str_replace( 'GLOBAL_', '', $cond['control'] ); } else { $field['condition'][ $k ]['control'] = $name . '_' . $cond['control']; } } } } $field['condition'] = array_merge( isset( $field['condition'] ) ? $field['condition'] : array(), array( array( 'control' => 'layout', 'value' => $name, ), ) ); Visual_Portfolio_Controls::register( $field ); } } Visual_Portfolio_Controls::register( array( 'category' => 'layouts', 'type' => 'range', 'label' => esc_html__( 'Gap', 'visual-portfolio' ), 'name' => 'items_gap', 'group' => 'layout_items_gap', 'default' => 15, 'min' => 0, 'max' => 200, 'reload_iframe' => false, 'style' => array( array( 'element' => '.vp-portfolio__items', 'property' => '--vp-items__gap', 'mask' => '$px', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'layouts', 'type' => 'range', 'label' => esc_html__( 'Vertical Gap', 'visual-portfolio' ), 'description' => esc_html__( 'When empty, used Gap option', 'visual-portfolio' ), 'name' => 'items_gap_vertical', 'group' => 'layout_items_gap', 'default' => '', 'min' => 0, 'max' => 200, 'reload_iframe' => false, 'style' => array( array( 'element' => '.vp-portfolio__items', 'property' => '--vp-items__gap-vertical', 'mask' => '$px', ), ), 'condition' => array( array( 'control' => 'layout', 'operator' => '!==', 'value' => 'slider', ), ), ) ); /** * Items Style */ $items_styles = Visual_Portfolio_Get::get_all_items_styles(); // Styles selector. $items_styles_selector = array(); foreach ( $items_styles as $style_name => $style ) { $items_styles_selector[ $style_name ] = array( 'value' => $style_name, 'title' => $style['title'], 'icon' => isset( $style['icon'] ) ? $style['icon'] : '', 'image_preview_wizard' => isset( $style['image_preview_wizard'] ) ? $style['image_preview_wizard'] : '', ); } Visual_Portfolio_Controls::register( array( 'category' => 'items-style', 'type' => 'icons_selector', 'name' => 'items_style', 'default' => 'fade', 'collapse_rows' => 2, 'options' => $items_styles_selector, 'setup_wizard' => true, ) ); Visual_Portfolio_Controls::register( array( 'category' => 'items-style', 'type' => 'category_navigator', 'name' => 'items_style_subcategory', 'initialOpen' => 'items-style-general', 'options' => array( array( 'title' => esc_html__( 'General', 'visual-portfolio' ), 'category' => 'items-style-general', ), array( 'title' => esc_html__( 'Image', 'visual-portfolio' ), 'category' => 'items-style-image', ), array( 'title' => esc_html__( 'Overlay', 'visual-portfolio' ), 'category' => 'items-style-overlay', ), array( 'title' => esc_html__( 'Caption', 'visual-portfolio' ), 'category' => 'items-style-caption', ), ), ) ); $builtin_default_options = array( 'image' => array( 'border_radius' => true, 'transform' => false, // Pro. 'css_filter' => false, // Pro. ), 'overlay' => array( 'states' => true, // All available align values: 'horizontal'|'vertical'|'box'. 'text_align' => 'box', 'under_image' => false, // Pro. // Elements. 'elements' => array( 'title' => false, 'categories' => false, 'date' => false, 'author' => false, 'comments_count' => false, 'views_count' => false, 'reading_time' => false, 'excerpt' => false, 'read_more' => false, 'icons' => false, ), // Colors. 'colors' => array( 'background' => true, 'text' => true, 'links' => false, 'mix_blend_mode' => false, // Pro. ), // Typography Pro. 'typography' => array( 'title' => false, 'category' => false, 'meta' => false, 'description' => false, 'button' => false, ), // Dimensions Pro. 'dimensions' => array( 'border_radius' => false, 'padding' => false, 'margin' => false, 'items_gap' => false, ), ), 'caption' => array( 'states' => true, // All available align values: 'horizontal'|'vertical'|'box'. 'text_align' => 'horizontal', 'under_image' => false, // Pro. // Elements. 'elements' => array( 'title' => false, 'categories' => false, 'date' => false, 'author' => false, 'comments_count' => false, 'views_count' => false, 'reading_time' => false, 'excerpt' => false, 'read_more' => false, 'icons' => false, ), // Colors. 'colors' => array( 'background' => false, 'text' => true, 'links' => true, 'mix_blend_mode' => false, // Pro. ), // Typography Pro. 'typography' => array( 'title' => false, 'category' => false, 'meta' => false, 'description' => false, 'button' => false, ), // Dimensions Pro. 'dimensions' => array( 'border_radius' => false, 'padding' => false, 'margin' => false, 'items_gap' => false, ), ), ); $builtin_default_options = apply_filters( 'vpf_items_style_builtin_controls_options', $builtin_default_options ); // styles builtin options. foreach ( $items_styles as $style_name => $style ) { $builtin_fields = array(); if ( ! empty( $style['builtin_controls'] ) ) { foreach ( $builtin_default_options as $category_name => $default_options ) { if ( empty( $style['builtin_controls'][ $category_name ] ) || ! $style['builtin_controls'][ $category_name ] ) { continue; } $options = $style['builtin_controls'][ $category_name ]; $new_fields = array(); switch ( $category_name ) { // Image. case 'image': $new_fields[] = array( 'type' => 'category_toggle_group', 'category' => 'items-style-image', 'name' => 'items_style_image_states', 'options' => array( array( 'title' => esc_html__( 'Normal', 'visual-portfolio' ), 'category' => 'items-style-image-normal', ), array( 'title' => esc_html__( 'Hover', 'visual-portfolio' ), 'category' => 'items-style-image-hover', ), ), ); if ( isset( $options['border_radius'] ) && $options['border_radius'] ) { $new_fields[] = array( 'type' => 'unit', 'category' => 'items-style-image-normal', 'label' => esc_html__( 'Border Radius', 'visual-portfolio' ), 'name' => 'images_rounded_corners', 'default' => '', 'style' => array( array( 'element' => '.vp-portfolio__items-style-' . $style_name, 'property' => '--vp-items-style-' . $style_name . '--image__border-radius', ), ), ); } if ( isset( $options['transform'] ) && $options['transform'] && isset( $options['css_filter'] ) && $options['css_filter'] ) { $new_fields[] = array( 'type' => 'pro_note', 'category' => 'items-style-image-normal', 'name' => 'additional_image_skin_settings_pro', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => 'Apply Instagram-like filters, change image transform', ); $new_fields[] = array( 'type' => 'pro_note', 'category' => 'items-style-image-hover', 'name' => 'additional_image_hover_skin_settings_pro', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => 'Apply Instagram-like filters, change image transform and border radius for both default and hover states', ); } break; // Overlay / Caption. case 'overlay': case 'caption': if ( isset( $options['states'] ) && $options['states'] ) { $new_fields[] = array( 'type' => 'select', 'category' => 'items-style-' . $category_name, 'label' => esc_html__( 'Display', 'visual-portfolio' ), 'name' => 'show_' . $category_name, 'default' => 'hover', 'options' => array( 'hover' => esc_html__( 'Hover State Only', 'visual-portfolio' ), 'default' => esc_html__( 'Default State Only', 'visual-portfolio' ), 'always' => esc_html__( 'Always', 'visual-portfolio' ), ), ); } if ( isset( $options['text_align'] ) && $options['text_align'] ) { $new_fields[] = array( 'type' => 'align', 'category' => 'items-style-' . $category_name, 'label' => esc_html__( 'Text Align', 'visual-portfolio' ), 'name' => $category_name . '_text_align', 'default' => 'center', 'options' => $options['text_align'], ); } $new_fields[] = array( 'type' => 'category_collapse', 'category' => 'items-style-' . $category_name, 'name' => 'items_style_' . $category_name . '_subcategory', 'options' => array( array( 'title' => esc_html__( 'Elements', 'visual-portfolio' ), 'category' => 'items-style-' . $category_name . '-elements', ), array( 'title' => esc_html__( 'Colors', 'visual-portfolio' ), 'category' => 'items-style-' . $category_name . '-colors', ), array( 'title' => esc_html__( 'Typography', 'visual-portfolio' ), 'category' => 'items-style-' . $category_name . '-typography', ), array( 'title' => esc_html__( 'Dimensions', 'visual-portfolio' ), 'category' => 'items-style-' . $category_name . '-dimensions', ), ), ); // Elements. if ( ! empty( $options['elements'] ) ) { $elements = $options['elements']; if ( isset( $elements['title'] ) && $elements['title'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Title', 'visual-portfolio' ), 'name' => 'show_title', 'group' => 'items_style_title', 'default' => true, ); $new_fields[] = array( 'type' => 'select', 'category' => 'items-style-' . $category_name . '-elements', 'label' => esc_html__( 'Title Tag', 'visual-portfolio' ), 'name' => 'title_tag', 'group' => 'items_style_title', 'default' => 'h2', 'options' => array( 'div' => '
', 'h1' => '

', 'h2' => '

', 'h3' => '

', 'h4' => '

', 'h5' => '

', 'h6' => '
', ), 'condition' => array( array( 'control' => 'show_title', ), ), ); } if ( isset( $elements['categories'] ) && $elements['categories'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Categories', 'visual-portfolio' ), 'name' => 'show_categories', 'group' => 'items_style_categories', 'default' => true, ); $new_fields[] = array( 'type' => 'range', 'category' => 'items-style-' . $category_name . '-elements', 'label' => esc_html__( 'Categories Count', 'visual-portfolio' ), 'name' => 'categories_count', 'group' => 'items_style_categories', 'min' => 1, 'max' => 20, 'default' => 1, 'condition' => array( array( 'control' => 'show_categories', ), ), ); } if ( isset( $elements['date'] ) && $elements['date'] ) { $new_fields[] = array( 'type' => 'select', 'category' => 'items-style-' . $category_name . '-elements', 'label' => esc_html__( 'Display Date', 'visual-portfolio' ), 'name' => 'show_date', 'group' => 'items_style_date', 'default' => 'false', 'options' => array( 'false' => esc_html__( 'Hide', 'visual-portfolio' ), 'true' => esc_html__( 'Default', 'visual-portfolio' ), 'human' => esc_html__( 'Human Format', 'visual-portfolio' ), ), ); $new_fields[] = array( 'type' => 'text', 'category' => 'items-style-' . $category_name . '-elements', 'name' => 'date_format', 'group' => 'items_style_date', 'default' => 'F j, Y', 'description' => esc_attr__( 'Date format example: F j, Y', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'show_date', ), ), ); } if ( isset( $elements['author'] ) && $elements['author'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Author', 'visual-portfolio' ), 'name' => 'show_author', 'default' => false, ); } if ( isset( $elements['comments_count'] ) && $elements['comments_count'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Comments Count', 'visual-portfolio' ), 'name' => 'show_comments_count', 'default' => false, 'condition' => array( array( 'control' => 'GLOBAL_content_source', 'value' => 'post-based', ), ), ); } if ( isset( $elements['views_count'] ) && $elements['views_count'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Views Count', 'visual-portfolio' ), 'name' => 'show_views_count', 'default' => false, 'condition' => array( array( 'control' => 'GLOBAL_content_source', 'value' => 'post-based', ), ), ); } if ( isset( $elements['reading_time'] ) && $elements['reading_time'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Reading Time', 'visual-portfolio' ), 'name' => 'show_reading_time', 'default' => false, 'condition' => array( array( 'control' => 'GLOBAL_content_source', 'value' => 'post-based', ), ), ); } if ( isset( $elements['excerpt'] ) && $elements['excerpt'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Excerpt', 'visual-portfolio' ), 'name' => 'show_excerpt', 'group' => 'items_style_excerpt', 'default' => false, ); $new_fields[] = array( 'type' => 'number', 'category' => 'items-style-' . $category_name . '-elements', 'label' => esc_html__( 'Excerpt Words Count', 'visual-portfolio' ), 'name' => 'excerpt_words_count', 'group' => 'items_style_excerpt', 'default' => 15, 'min' => 1, 'max' => 200, 'condition' => array( array( 'control' => 'show_excerpt', ), ), ); } if ( isset( $elements['read_more'] ) && $elements['read_more'] ) { $new_fields[] = array( 'type' => 'select', 'category' => 'items-style-' . $category_name . '-elements', 'label' => esc_html__( 'Display Read More Button', 'visual-portfolio' ), 'name' => 'show_read_more', 'group' => 'items_style_read_more', 'default' => 'false', 'options' => array( 'false' => esc_html__( 'Hide', 'visual-portfolio' ), 'true' => esc_html__( 'Always Display', 'visual-portfolio' ), 'more_tag' => esc_html__( 'Display when used `More tag` in the post', 'visual-portfolio' ), ), ); $new_fields[] = array( 'type' => 'text', 'category' => 'items-style-' . $category_name . '-elements', 'name' => 'read_more_label', 'group' => 'items_style_read_more', 'default' => 'Read More', 'description' => esc_attr__( 'Read More button label', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'show_read_more', 'operator' => '!=', 'value' => 'false', ), ), ); } if ( isset( $elements['icons'] ) && $elements['icons'] ) { $new_fields[] = array( 'type' => 'checkbox', 'category' => 'items-style-' . $category_name . '-elements', 'alongside' => esc_html__( 'Display Icon', 'visual-portfolio' ), 'name' => 'show_icon', 'default' => false, ); } } // Colors. if ( ! empty( $options['colors'] ) ) { $has_background = isset( $options['colors']['background'] ) && $options['colors']['background']; $has_text = isset( $options['colors']['text'] ) && $options['colors']['text']; $has_links = isset( $options['colors']['links'] ) && $options['colors']['links']; $has_blend_mode = isset( $options['colors']['mix_blend_mode'] ) && $options['colors']['mix_blend_mode']; if ( $has_background ) { $new_fields[] = array( 'type' => 'color', 'category' => 'items-style-' . $category_name . '-colors', 'label' => esc_html__( 'Background', 'visual-portfolio' ), 'name' => $category_name . '_bg_color', 'alpha' => true, 'gradient' => true, 'style' => array( array( 'element' => '.vp-portfolio__items-style-' . $style_name, 'property' => '--vp-items-style-' . $style_name . '--' . $category_name . '__background', ), ), ); } if ( $has_text ) { $new_fields[] = array( 'type' => 'color', 'category' => 'items-style-' . $category_name . '-colors', 'label' => esc_html__( 'Text', 'visual-portfolio' ), 'name' => $category_name . '_text_color', 'alpha' => true, 'style' => array( array( 'element' => '.vp-portfolio__items-style-' . $style_name, 'property' => '--vp-items-style-' . $style_name . '--' . $category_name . '__color', ), ), ); } if ( $has_links ) { $new_fields[] = array( 'type' => 'color', 'category' => 'items-style-' . $category_name . '-colors', 'label' => esc_html__( 'Links', 'visual-portfolio' ), 'name' => $category_name . '_links_color', 'alpha' => true, 'style' => array( array( 'element' => '.vp-portfolio__items-style-' . $style_name, 'property' => '--vp-items-style-' . $style_name . '--' . $category_name . '-links__color', ), ), ); $new_fields[] = array( 'type' => 'color', 'category' => 'items-style-' . $category_name . '-colors', 'label' => esc_html__( 'Links Hover', 'visual-portfolio' ), 'name' => $category_name . '_links_hover_color', 'alpha' => true, 'style' => array( array( 'element' => '.vp-portfolio__items-style-' . $style_name, 'property' => '--vp-items-style-' . $style_name . '--' . $category_name . '-links-hover__color', ), ), ); } // Mix Blend Mode Pro. if ( $has_blend_mode ) { $new_fields[] = array( 'type' => 'pro_note', 'category' => 'items-style-' . $category_name . '-colors', 'name' => 'additional_' . $category_name . '_mix_blend_mode_skin_settings_pro', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => 'Select blend mode layer effects such as Normal, Multiply, Screen, Overlay, and more', ); } } // Typography. if ( ! empty( $options['typography'] ) ) { $new_fields[] = array( 'type' => 'pro_note', 'category' => 'items-style-' . $category_name . '-typography', 'name' => 'additional_' . $category_name . '_typography_skin_settings_pro', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => 'Manage fonts, sizing, and appearance of distinct text components within the Skin', ); } // Dimensions. if ( ! empty( $options['dimensions'] ) ) { $has_border_radius = isset( $options['dimensions']['border_radius'] ) && $options['dimensions']['border_radius']; $has_padding = isset( $options['dimensions']['padding'] ) && $options['dimensions']['padding']; $has_margin = isset( $options['dimensions']['margin'] ) && $options['dimensions']['margin']; $has_items_gap = isset( $options['dimensions']['items_gap'] ) && $options['dimensions']['items_gap']; $dimensions_list = array(); if ( $has_border_radius ) { $dimensions_list[] = 'border radius'; } if ( $has_padding ) { $dimensions_list[] = 'padding'; } if ( $has_margin ) { $dimensions_list[] = 'margin'; } if ( $has_items_gap ) { $dimensions_list[] = 'gap between elements'; } $new_fields[] = array( 'type' => 'pro_note', 'category' => 'items-style-' . $category_name . '-dimensions', 'name' => 'additional_' . $category_name . '_dimensions_skin_settings_pro', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => 'Adjust element spacing and dimensions such as ' . implode( ', ', $dimensions_list ), ); } break; // no default. } $builtin_fields = array_merge( $builtin_fields, apply_filters( 'vpf_items_style_builtin_controls', $new_fields, $category_name, $options, $style_name, $style ) ); } } $items_styles[ $style_name ]['controls'] = array_merge( $builtin_fields, isset( $style['controls'] ) ? $style['controls'] : array() ); } // styles options. foreach ( $items_styles as $style_name => $style ) { if ( ! isset( $style['controls'] ) ) { continue; } foreach ( $style['controls'] as $field ) { $field['category'] = $field['category'] ?? 'items-style'; $field['name'] = 'items_style_' . $style_name . '__' . $field['name']; // condition names prefix fix. if ( isset( $field['condition'] ) ) { $loop_over_conditions = function( $field_cond ) use ( &$loop_over_conditions, $style_name ) { if ( is_array( $field_cond ) && ! isset( $field_cond['control'] ) ) { foreach ( $field_cond as $k => $inner_cond ) { $field_cond[ $k ] = $loop_over_conditions( $inner_cond ); } } elseif ( isset( $field_cond['control'] ) ) { if ( strpos( $field_cond['control'], 'GLOBAL_' ) === 0 ) { $field_cond['control'] = str_replace( 'GLOBAL_', '', $field_cond['control'] ); } else { $field_cond['control'] = 'items_style_' . $style_name . '__' . $field_cond['control']; } } return $field_cond; }; $field['condition'] = $loop_over_conditions( $field['condition'] ); } $field['condition'] = array_merge( isset( $field['condition'] ) ? $field['condition'] : array(), array( array( 'control' => 'items_style', 'value' => $style_name, ), ) ); Visual_Portfolio_Controls::register( $field ); } } /** * Items Click Action */ Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'icons_selector', 'name' => 'items_click_action', 'default' => 'url', 'options' => array( array( 'value' => 'false', 'title' => esc_html__( 'Disabled', 'visual-portfolio' ), 'icon' => '', ), array( 'value' => 'url', 'title' => esc_html__( 'URL', 'visual-portfolio' ), 'icon' => '', ), array( 'value' => 'popup_gallery', 'title' => esc_html__( 'Popup', 'visual-portfolio' ), 'icon' => '', ), array( 'value' => 'advanced', 'title' => esc_html__( 'Advanced', 'visual-portfolio' ), 'icon' => '', ), ), ) ); // url. Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'radio', 'label' => esc_html__( 'Target', 'visual-portfolio' ), 'name' => 'items_click_action_url_target', 'group' => 'items_click_action_target', 'default' => '', 'reload_iframe' => false, 'options' => array( '' => esc_html__( 'Default', 'visual-portfolio' ), '_blank' => esc_html__( 'New Tab (_blank)', 'visual-portfolio' ), '_top' => esc_html__( 'Top Frame (_top)', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'url', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'text', 'label' => esc_html__( 'Rel', 'visual-portfolio' ), 'name' => 'items_click_action_url_rel', 'group' => 'items_click_action_target', 'default' => '', 'reload_iframe' => false, 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'url', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'pro_note', 'name' => 'items_click_action_url_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '

' . esc_html__( 'Link URL click priority', 'visual-portfolio' ) . '

', 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'url', ), ), ) ); // popup. Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'select', 'label' => esc_html__( 'Title Source', 'visual-portfolio' ), 'name' => 'items_click_action_popup_title_source', 'group' => 'popup_title_source', 'default' => 'title', 'reload_iframe' => false, 'options' => array( 'none' => esc_html__( 'None', 'visual-portfolio' ), 'title' => esc_html__( 'Image Title', 'visual-portfolio' ), 'caption' => esc_html__( 'Image Caption', 'visual-portfolio' ), 'alt' => esc_html__( 'Image Alt', 'visual-portfolio' ), 'description' => esc_html__( 'Image Description', 'visual-portfolio' ), 'item_title' => esc_html__( 'Item Title', 'visual-portfolio' ), 'item_description' => esc_html__( 'Item Description', 'visual-portfolio' ), 'item_author' => esc_html__( 'Item Author', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'popup_gallery', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'select', 'label' => esc_html__( 'Description Source', 'visual-portfolio' ), 'name' => 'items_click_action_popup_description_source', 'group' => 'popup_title_source', 'default' => 'description', 'reload_iframe' => false, 'options' => array( 'none' => esc_html__( 'None', 'visual-portfolio' ), 'title' => esc_html__( 'Image Title', 'visual-portfolio' ), 'caption' => esc_html__( 'Image Caption', 'visual-portfolio' ), 'alt' => esc_html__( 'Image Alt', 'visual-portfolio' ), 'description' => esc_html__( 'Image Description', 'visual-portfolio' ), 'item_title' => esc_html__( 'Item Title', 'visual-portfolio' ), 'item_description' => esc_html__( 'Item Description', 'visual-portfolio' ), 'item_author' => esc_html__( 'Item Author', 'visual-portfolio' ), ), 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'popup_gallery', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'pro_note', 'name' => 'items_click_action_popup_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '', 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'popup_gallery', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'items-click-action', 'type' => 'pro_note', 'name' => 'items_click_action_advanced_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '

' . esc_html__( 'Deeply customize actions of clicks on different types of items and links.', 'visual-portfolio' ) . '

', 'condition' => array( array( 'control' => 'items_click_action', 'value' => 'advanced', ), ), ) ); /** * Layout Elements. */ Visual_Portfolio_Controls::register( array( 'category' => 'layout-elements', 'type' => 'elements_selector', 'name' => 'layout_elements', 'locations' => array( 'top' => array( 'title' => esc_html__( 'Start', 'visual-portfolio' ), 'align' => array( 'left', 'center', 'right', 'between', ), ), 'items' => array( 'title' => esc_html__( 'Middle', 'visual-portfolio' ), ), 'bottom' => array( 'title' => esc_html__( 'End', 'visual-portfolio' ), 'align' => array( 'left', 'center', 'right', 'between', ), ), ), 'default' => array( 'top' => array( 'elements' => array(), 'align' => 'center', ), 'items' => array( 'elements' => array( 'items' ), ), 'bottom' => array( 'elements' => array(), 'align' => 'center', ), ), 'options' => array( 'filter' => array( 'title' => esc_html__( 'Filter', 'visual-portfolio' ), 'allowed_locations' => array( 'top' ), 'category' => 'filter', 'render_callback' => 'Visual_Portfolio_Get::filter', ), 'sort' => array( 'title' => esc_html__( 'Sort', 'visual-portfolio' ), 'allowed_locations' => array( 'top' ), 'category' => 'sort', 'render_callback' => 'Visual_Portfolio_Get::sort', ), 'search' => array( 'title' => esc_html__( 'Search', 'visual-portfolio' ), 'allowed_locations' => array( 'top' ), 'category' => 'search', 'is_pro' => true, ), 'items' => array( 'title' => esc_html__( 'Layout Items', 'visual-portfolio' ), 'allowed_locations' => array( 'items' ), 'category' => 'layouts', ), 'pagination' => array( 'title' => esc_html__( 'Pagination', 'visual-portfolio' ), 'allowed_locations' => array( 'bottom' ), 'category' => 'pagination', 'render_callback' => 'Visual_Portfolio_Get::pagination', ), ), ) ); /** * Filter. */ $filters = array_merge( array( // Minimal. 'minimal' => array( 'title' => esc_html__( 'Minimal', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), // Classic. 'default' => array( 'title' => esc_html__( 'Classic', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), // Dropdown. 'dropdown' => array( 'title' => esc_html__( 'Dropdown', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), ), // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( 'new_filter' => array( 'title' => esc_html__( 'New Filter', 'visual-portfolio' ), 'controls' => array( ... controls ... ), ), ) */ apply_filters( 'vpf_extend_filters', array() ) ); // Extend specific filter controls. foreach ( $filters as $name => $filter ) { if ( isset( $filter['controls'] ) ) { // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( ... controls ... ) */ $filters[ $name ]['controls'] = apply_filters( 'vpf_extend_filter_' . $name . '_controls', $filter['controls'] ); } } // Filters selector. $filters_selector = array(); foreach ( $filters as $name => $filter ) { $filters_selector[] = array( 'value' => $name, 'title' => $filter['title'], 'icon' => isset( $filter['icon'] ) ? $filter['icon'] : '', ); } Visual_Portfolio_Controls::register( array( 'category' => 'filter', 'type' => 'icons_selector', 'name' => 'filter', 'default' => 'minimal', 'options' => $filters_selector, 'setup_wizard' => true, ) ); // filters options. foreach ( $filters as $name => $filter ) { if ( ! isset( $filter['controls'] ) ) { continue; } foreach ( $filter['controls'] as $field ) { $field['category'] = 'filter'; $field['name'] = 'filter_' . $name . '__' . $field['name']; // condition names prefix fix. if ( isset( $field['condition'] ) ) { foreach ( $field['condition'] as $k => $cond ) { if ( isset( $cond['control'] ) ) { if ( strpos( $cond['control'], 'GLOBAL_' ) === 0 ) { $field['condition'][ $k ]['control'] = str_replace( 'GLOBAL_', '', $cond['control'] ); } else { $field['condition'][ $k ]['control'] = $name . '_' . $cond['control']; } } } } $field['condition'] = array_merge( isset( $field['condition'] ) ? $field['condition'] : array(), array( array( 'control' => 'filter', 'value' => $name, ), ) ); Visual_Portfolio_Controls::register( $field ); } } Visual_Portfolio_Controls::register( array( 'category' => 'filter', 'type' => 'checkbox', 'alongside' => esc_html__( 'Display Count', 'visual-portfolio' ), 'name' => 'filter_show_count', 'default' => false, ) ); Visual_Portfolio_Controls::register( array( 'category' => 'filter', 'type' => 'text', 'label' => esc_html__( 'All Button Text', 'visual-portfolio' ), 'name' => 'filter_text_all', 'default' => esc_attr__( 'All', 'visual-portfolio' ), 'wpml' => true, ) ); /** * Sort. */ $sorts = array_merge( array( // Minimal. 'minimal' => array( 'title' => esc_html__( 'Minimal', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), // Classic. 'default' => array( 'title' => esc_html__( 'Classic', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), // Dropdown. 'dropdown' => array( 'title' => esc_html__( 'Dropdown', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), ), // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( 'new_sort' => array( 'title' => esc_html__( 'New Sort', 'visual-portfolio' ), 'controls' => array( ... controls ... ), ), ) */ apply_filters( 'vpf_extend_sort', array() ) ); // Extend specific sort controls. foreach ( $sorts as $name => $sort ) { if ( isset( $sort['controls'] ) ) { // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( ... controls ... ) */ $sorts[ $name ]['controls'] = apply_filters( 'vpf_extend_sort_' . $name . '_controls', $sort['controls'] ); } } // Sort selector. $sorts_selector = array(); foreach ( $sorts as $name => $sort ) { $sorts_selector[ $name ] = array( 'value' => $name, 'title' => $sort['title'], 'icon' => isset( $sort['icon'] ) ? $sort['icon'] : '', ); } Visual_Portfolio_Controls::register( array( 'category' => 'sort', 'type' => 'icons_selector', 'name' => 'sort', 'default' => 'dropdown', 'options' => $sorts_selector, ) ); // sorts options. foreach ( $sorts as $name => $sort ) { if ( ! isset( $sort['controls'] ) ) { continue; } foreach ( $sort['controls'] as $field ) { $field['category'] = 'sort'; $field['name'] = 'sort_' . $name . '__' . $field['name']; // condition names prefix fix. if ( isset( $field['condition'] ) ) { foreach ( $field['condition'] as $k => $cond ) { if ( isset( $cond['control'] ) ) { if ( strpos( $cond['control'], 'GLOBAL_' ) === 0 ) { $field['condition'][ $k ]['control'] = str_replace( 'GLOBAL_', '', $cond['control'] ); } else { $field['condition'][ $k ]['control'] = $name . '_' . $cond['control']; } } } } $field['condition'] = array_merge( isset( $field['condition'] ) ? $field['condition'] : array(), array( array( 'control' => 'sort', 'value' => $name, ), ) ); Visual_Portfolio_Controls::register( $field ); } } /** * Search */ Visual_Portfolio_Controls::register( array( 'category' => 'search', 'type' => 'pro_note', 'name' => 'search_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '

' . esc_html__( 'The search module is only available for Pro users.', 'visual-portfolio' ) . '

', ) ); /** * Pagination */ $pagination = array_merge( array( // Minimal. 'minimal' => array( 'title' => esc_html__( 'Minimal', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), // Classic. 'default' => array( 'title' => esc_html__( 'Classic', 'visual-portfolio' ), 'icon' => '', 'controls' => array(), ), ), // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( 'new_pagination' => array( 'title' => esc_html__( 'New Pagination', 'visual-portfolio' ), 'controls' => array( ... controls ... ), ), ) */ apply_filters( 'vpf_extend_pagination', array() ) ); // Extend specific pagination controls. foreach ( $pagination as $name => $pagin ) { if ( isset( $pagin['controls'] ) ) { // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( ... controls ... ) */ $pagination[ $name ]['controls'] = apply_filters( 'vpf_extend_pagination_' . $name . '_controls', $pagin['controls'] ); } } // Pagination selector. $pagination_selector = array(); foreach ( $pagination as $name => $pagin ) { $pagination_selector[ $name ] = array( 'value' => $name, 'title' => $pagin['title'], 'icon' => isset( $pagin['icon'] ) ? $pagin['icon'] : '', ); } Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'icons_selector', 'name' => 'pagination_style', 'default' => 'minimal', 'options' => $pagination_selector, ) ); // pagination options. foreach ( $pagination as $name => $pagin ) { if ( ! isset( $pagin['controls'] ) ) { continue; } foreach ( $pagin['controls'] as $field ) { $field['category'] = 'pagination'; $field['name'] = 'pagination_' . $name . '__' . $field['name']; // condition names prefix fix. if ( isset( $field['condition'] ) ) { foreach ( $field['condition'] as $k => $cond ) { if ( isset( $cond['control'] ) ) { $field['condition'][ $k ]['control'] = $name . '_' . $cond['control']; } } } $field['condition'] = array_merge( isset( $field['condition'] ) ? $field['condition'] : array(), array( array( 'control' => 'pagination_style', 'value' => $name, ), ) ); Visual_Portfolio_Controls::register( $field ); } } Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'label' => esc_html__( 'Type', 'visual-portfolio' ), 'type' => 'icons_selector', 'name' => 'pagination', 'default' => 'load-more', 'options' => array( array( 'value' => 'paged', 'title' => esc_html__( 'Paged', 'visual-portfolio' ), 'icon' => '', ), array( 'value' => 'load-more', 'title' => esc_html__( 'Load More', 'visual-portfolio' ), 'icon' => '', ), array( 'value' => 'infinite', 'title' => esc_html__( 'Infinite', 'visual-portfolio' ), 'icon' => '', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'html', 'description' => esc_html__( 'Note: you will see the "Load More" pagination in the preview. "Infinite" pagination will be visible on the site.', 'visual-portfolio' ), 'name' => 'pagination_infinite_notice', 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'infinite', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'text', 'label' => esc_html__( 'Texts', 'visual-portfolio' ), 'name' => 'pagination_infinite_text_load', 'group' => 'pagination_texts', 'default' => esc_attr__( 'Load More', 'visual-portfolio' ), 'description' => esc_attr__( 'Load more button label', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'infinite', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'text', 'name' => 'pagination_infinite_text_loading', 'group' => 'pagination_texts', 'default' => esc_attr__( 'Loading More...', 'visual-portfolio' ), 'description' => esc_attr__( 'Loading more button label', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'infinite', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'textarea', 'name' => 'pagination_infinite_text_end_list', 'group' => 'pagination_texts', 'default' => esc_attr__( 'You’ve reached the end of the list', 'visual-portfolio' ), 'description' => esc_attr__( 'End of the list text', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'infinite', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'text', 'label' => esc_html__( 'Texts', 'visual-portfolio' ), 'name' => 'pagination_load_more_text_load', 'group' => 'pagination_texts', 'default' => esc_attr__( 'Load More', 'visual-portfolio' ), 'description' => esc_attr__( 'Load more button label', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'load-more', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'text', 'name' => 'pagination_load_more_text_loading', 'group' => 'pagination_texts', 'default' => esc_attr__( 'Loading More...', 'visual-portfolio' ), 'description' => esc_attr__( 'Loading more button label', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'load-more', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'textarea', 'name' => 'pagination_load_more_text_end_list', 'group' => 'pagination_texts', 'default' => esc_attr__( 'You’ve reached the end of the list', 'visual-portfolio' ), 'description' => esc_attr__( 'End of the list text', 'visual-portfolio' ), 'wpml' => true, 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'load-more', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'checkbox', 'alongside' => esc_html__( 'Display Arrows', 'visual-portfolio' ), 'name' => 'pagination_paged__show_arrows', 'default' => true, 'condition' => array( array( 'control' => 'pagination', 'value' => 'paged', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'checkbox', 'alongside' => esc_html__( 'Display Numbers', 'visual-portfolio' ), 'name' => 'pagination_paged__show_numbers', 'default' => true, 'condition' => array( array( 'control' => 'pagination', 'value' => 'paged', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'checkbox', 'alongside' => esc_html__( 'Scroll to Top', 'visual-portfolio' ), 'name' => 'pagination_paged__scroll_top', 'group' => 'pagination_scroll_top', 'default' => true, 'reload_iframe' => false, 'condition' => array( array( 'control' => 'pagination', 'value' => 'paged', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'number', 'label' => esc_html__( 'Scroll to Top Offset', 'visual-portfolio' ), 'name' => 'pagination_paged__scroll_top_offset', 'group' => 'pagination_scroll_top', 'default' => 30, 'reload_iframe' => false, 'condition' => array( array( 'control' => 'pagination', 'value' => 'paged', ), array( 'control' => 'pagination_paged__scroll_top', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'checkbox', 'alongside' => esc_html__( 'Hide on Reached End', 'visual-portfolio' ), 'name' => 'pagination_hide_on_end', 'default' => false, 'condition' => array( array( 'control' => 'pagination', 'operator' => '!=', 'value' => 'paged', ), ), ) ); Visual_Portfolio_Controls::register( array( 'category' => 'pagination', 'type' => 'pro_note', 'name' => 'pagination_infinite_additional_options_pro_note', 'label' => esc_html__( 'Premium Only', 'visual-portfolio' ), 'description' => '

' . esc_html__( 'Adjust the loading threshold, limit the number of automatic loads and run the infinite scroll only after the Load button click.', 'visual-portfolio' ) . '

', 'condition' => array( array( 'control' => 'pagination', 'operator' => '==', 'value' => 'infinite', ), ), ) ); /** * Code Editor */ Visual_Portfolio_Controls::register( array( 'category' => 'custom_css', 'type' => 'code_editor', 'name' => 'custom_css', 'max_lines' => 20, 'min_lines' => 5, 'mode' => 'css', 'allow_modal' => true, 'classes_tree' => true, 'encode' => true, 'reload_iframe' => false, 'code_placeholder' => "selector {\n\n}", 'default' => '', 'description' => '

' . wp_kses_post( __( 'Use selector rule to change block styles.', 'visual-portfolio' ) ) . '

' . esc_html__( 'Example:', 'visual-portfolio' ) . '

selector {
    background-color: #5C39A7;
}

selector p {
    color: #5C39A7;
}
', ) ); do_action( 'vpf_after_register_controls' ); } /** * Find post types options for control. * * @return array */ public function find_post_types_options() { check_ajax_referer( 'vp-ajax-nonce', 'nonce' ); // post types list. $post_types = get_post_types( array( 'public' => false, 'name' => 'attachment', ), 'names', 'NOT' ); $post_types_selector = array(); if ( is_array( $post_types ) && ! empty( $post_types ) ) { foreach ( $post_types as $post_type ) { $post_types_selector[ $post_type ] = array( 'value' => $post_type, 'title' => ucfirst( $post_type ), 'icon' => '', ); } } $post_types_selector['post_types_set'] = array( 'value' => 'post_types_set', 'title' => esc_html__( 'Post Types Set', 'visual-portfolio' ), 'icon' => '', ); $post_types_selector['ids'] = array( 'value' => 'ids', 'title' => esc_html__( 'Manual Selection', 'visual-portfolio' ), 'icon' => '', ); $post_types_selector['custom_query'] = array( 'value' => 'custom_query', 'title' => esc_html__( 'Custom Query', 'visual-portfolio' ), 'icon' => '', ); $post_types_selector['current_query'] = array( 'value' => 'current_query', 'title' => esc_html__( 'Current Query', 'visual-portfolio' ), 'icon' => '', ); $post_types_selector = array_merge( $post_types_selector, // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoEmptyLineBefore /* * Example: array( 'new_post_source' => array( 'value' => 'new_post_source', 'title' => esc_html__( 'New Post Source', 'visual-portfolio' ), 'icon' => '', ), ) */ apply_filters( 'vpf_extend_posts_source', array() ) ); return array( 'options' => $post_types_selector, ); } /** * Find post types for select control. * * @return array */ public function find_posts_types_select_control() { check_ajax_referer( 'vp-ajax-nonce', 'nonce' ); $result = array(); // post types list. $post_types = get_post_types( array( 'public' => false, 'name' => 'attachment', ), 'names', 'NOT' ); if ( is_array( $post_types ) && ! empty( $post_types ) ) { $result['options'] = array(); foreach ( $post_types as $post_type ) { $result['options'][ $post_type ] = array( 'value' => $post_type, 'label' => ucfirst( $post_type ), ); } } return $result; } /** * Find posts for select control. * * @param array $attributes - current block attributes. * @param array $control - current control. * * @return array */ public function find_posts_select_control( $attributes, $control ) { check_ajax_referer( 'vp-ajax-nonce', 'nonce' ); $result = array(); // get selected options. $selected_ids = isset( $attributes[ $control['name'] ] ) ? $attributes[ $control['name'] ] : array(); if ( ! isset( $_POST['q'] ) && empty( $selected_ids ) ) { return $result; } $post_type = isset( $attributes['posts_source'] ) ? sanitize_text_field( wp_unslash( $attributes['posts_source'] ) ) : 'any'; if ( ! $post_type || 'post_types_set' === $post_type || 'custom_query' === $post_type || 'ids' === $post_type ) { $post_type = 'any'; } if ( isset( $_POST['q'] ) ) { $the_query = new WP_Query( array( 's' => sanitize_text_field( wp_unslash( $_POST['q'] ) ), 'posts_per_page' => 50, 'post_type' => $post_type, ) ); } else { $the_query = new WP_Query( array( 'post__in' => $selected_ids, 'posts_per_page' => 50, 'post_type' => $post_type, ) ); } if ( $the_query->have_posts() ) { $result['options'] = array(); while ( $the_query->have_posts() ) { $the_query->the_post(); $result['options'][ (string) get_the_ID() ] = array( 'value' => (string) get_the_ID(), 'label' => get_the_title(), 'img' => get_the_post_thumbnail_url( null, 'thumbnail' ), 'category' => get_post_type( get_the_ID() ), ); } $the_query->reset_postdata(); } return $result; } /** * Find taxonomies for select control. * * @param array $attributes - current block attributes. * @param array $control - current control. * * @return array */ public function find_taxonomies_select_control( $attributes, $control ) { check_ajax_referer( 'vp-ajax-nonce', 'nonce' ); $result = array(); // get selected options. $selected_ids = isset( $attributes[ $control['name'] ] ) ? $attributes[ $control['name'] ] : array(); if ( ! isset( $_POST['q'] ) && empty( $selected_ids ) ) { return $result; } if ( isset( $_POST['q'] ) ) { $post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) : 'any'; if ( ! $post_type || 'post_types_set' === $post_type || 'custom_query' === $post_type || 'ids' === $post_type ) { $post_type = 'any'; } // get taxonomies for selected post type or all available. if ( 'any' === $post_type ) { $post_type = get_post_types( array( 'public' => false, 'name' => 'attachment', ), 'names', 'NOT' ); } $taxonomies_names = get_object_taxonomies( $post_type ); $the_query = new WP_Term_Query( array( 'taxonomy' => $taxonomies_names, 'hide_empty' => false, 'search' => sanitize_text_field( wp_unslash( $_POST['q'] ) ), ) ); } else { $the_query = new WP_Term_Query( array( 'include' => $selected_ids, 'hide_empty' => false, ) ); } if ( ! empty( $the_query->terms ) ) { $result['options'] = array(); foreach ( $the_query->terms as $term ) { $result['options'][ (string) $term->term_id ] = array( 'value' => (string) $term->term_id, 'label' => $term->name, 'category' => $term->taxonomy, ); } } return $result; } /** * Find taxonomies ajax */ public function ajax_find_oembed() { check_ajax_referer( 'vp-ajax-nonce', 'nonce' ); if ( ! isset( $_POST['q'] ) ) { wp_die(); } $oembed = visual_portfolio()->get_oembed_data( sanitize_text_field( wp_unslash( $_POST['q'] ) ) ); if ( ! isset( $oembed ) || ! $oembed || ! isset( $oembed['html'] ) ) { wp_die(); } echo wp_json_encode( $oembed ); wp_die(); } } new Visual_Portfolio_Admin();