version = ADV_VIS_ELE_VERSION; } else { $this->version = '1.0.0'; } $this->plugin_name = 'advanced-visual-elements'; $this->load_dependencies(); $this->set_locale(); $this->library = new Adv_Vis_Ele_Library(); $this->define_admin_hooks(); $this->define_public_hooks(); $this->load_elements_editor(); } private function load_dependencies() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-adv-vis-ele-helpers.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-adv-vis-ele-loader.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-adv-vis-ele-i18n.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-adv-vis-ele-admin.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-adv-vis-ele-elementor.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-adv-vis-ele-gutenberg.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-adv-vis-ele-public.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-adv-vis-ele-library.php'; $this->loader = new Adv_Vis_Ele_Loader(); } private function set_locale() { $plugin_i18n = new Adv_Vis_Ele_i18n(); $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); } private function define_admin_hooks() { $plugin_admin = new Adv_Vis_Ele_Admin($this->get_plugin_name(), $this->get_version()); $gutenberg_shortcode = new Adv_Vis_Ele_Gutenberg_Shortcode(); if ( get_option( 'adv_vis_ele_enable_default_meta_viewport' ) == 'on' ) { $this->loader->add_action( 'wp_head', $plugin_admin, 'add_viewport_meta_tag' ); } $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'create_plugin_admin_page' ); $this->loader->add_action( 'wp_ajax_adv_vis_ele_ajax_load_more_elements', $this->library, 'ajax_load_more_elements' ); $this->loader->add_action( 'wp_ajax_adv_vis_ele_ajax_import_settings', $this, 'ajax_import_settings' ); $this->loader->add_action( 'wp_ajax_adv_vis_ele_ajax_full_import', $this->library, 'ajax_full_import' ); $this->loader->add_action( 'wp_ajax_adv_vis_ele_ajax_quick_save', $this->library, 'ajax_quick_save' ); $this->loader->add_action( 'edit_form_after_editor', $this, 'element_settings_editor' ); $this->loader->add_action( 'publish_adv-vis-element', $plugin_admin, 'on_publish_element' ); $this->loader->add_action( 'draft_adv-vis-element', $plugin_admin, 'on_publish_element' ); $this->loader->add_action( 'transition_post_status', $plugin_admin, 'on_transition_element', 10, 3 ); $this->loader->add_action( 'manage_adv-vis-element_posts_custom_column', $plugin_admin, 'populate_shortcodes_in_element_list', 10, 2 ); $this->loader->add_filter( 'manage_adv-vis-element_posts_columns', $plugin_admin, 'add_shortcodes_to_element_list' ); $this->loader->add_filter( 'post_row_actions', $plugin_admin, 'add_preview_link', 10, 2 ); $this->loader->add_filter( 'post_row_actions', $plugin_admin, 'add_duplicate_button', 10, 2 ); $this->loader->add_action( 'admin_init', $plugin_admin, 'duplicate_element' ); $this->loader->add_action( 'admin_init', $plugin_admin, 'register_plugin_settings' ); $this->loader->add_filter( 'plugin_action_links_wp-ave/wp-ave.php', $plugin_admin, 'add_plugin_page_links' ); $this->loader->add_filter( 'admin_body_class', $plugin_admin, 'add_editor_body_classes' ); $this->loader->add_filter( 'parent_file', $plugin_admin, 'keep_admin_menu_parent_item_open' ); $this->loader->add_action( 'post_submitbox_misc_actions', $plugin_admin, 'add_links_to_publish_box' ); $this->loader->add_filter( 'wp_loaded', $plugin_admin, 'quick_preview' ); $this->loader->add_action( 'init', $gutenberg_shortcode, 'gutenberg_shortcode_block' ); $this->loader->add_filter( 'use_block_editor_for_post_type', $this, 'disable_gutenberg', PHP_INT_MAX, 2 ); $this->loader->add_action( 'admin_footer', $plugin_admin, 'render_help_box', PHP_INT_MAX ); $this->loader->add_action( 'upgrader_process_complete', $this, 'delete_library_info', 10, 2 ); if ( Adv_Vis_Ele_Admin::is_dev() ) { $this->loader->add_action( 'admin_footer', $plugin_admin, 'dev_control_dashboard', PHP_INT_MAX ); } } private function define_public_hooks() { $plugin_public = new Adv_Vis_Ele_Public($this->get_plugin_name(), $this->get_version()); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'register_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'register_scripts' ); $this->loader->add_action( 'elementor/frontend/after_enqueue_styles', $plugin_public, 'enqueue_element_scripts' ); } public function run() { $this->loader->run(); } public function get_plugin_name() { return $this->plugin_name; } public function get_loader() { return $this->loader; } public function get_version() { return $this->version; } public function load_elements_editor() { $this->loader->add_action( 'init', $this, 'register_cpt_adv_vis_element' ); } public function register_cpt_adv_vis_element() { $labels = [ "name" => __( "Elements", 'advanced-visual-elements' ), "singular_name" => __( "Element", 'advanced-visual-elements' ), "menu_name" => __( "My Elements", 'advanced-visual-elements' ), "all_items" => __( "All Elements", 'advanced-visual-elements' ), "add_new" => __( "Add new", 'advanced-visual-elements' ), "add_new_item" => __( "Add new Element", 'advanced-visual-elements' ), "edit_item" => __( "Edit Element", 'advanced-visual-elements' ), "new_item" => __( "New Element", 'advanced-visual-elements' ), "view_item" => __( "View Element", 'advanced-visual-elements' ), "view_items" => __( "View Elements", 'advanced-visual-elements' ), "search_items" => __( "Search Elements", 'advanced-visual-elements' ), "not_found" => __( "No Elements found", 'advanced-visual-elements' ), "not_found_in_trash" => __( "No Elements found in trash", 'advanced-visual-elements' ), "parent" => __( "Parent Element:", 'advanced-visual-elements' ), "featured_image" => __( "Featured image for this Element", 'advanced-visual-elements' ), "set_featured_image" => __( "Set featured image for this Element", 'advanced-visual-elements' ), "remove_featured_image" => __( "Remove featured image for this Element", 'advanced-visual-elements' ), "use_featured_image" => __( "Use as featured image for this Element", 'advanced-visual-elements' ), "archives" => __( "Element archives", 'advanced-visual-elements' ), "insert_into_item" => __( "Insert into Element", 'advanced-visual-elements' ), "uploaded_to_this_item" => __( "Upload to this Element", 'advanced-visual-elements' ), "filter_items_list" => __( "Filter Elements list", 'advanced-visual-elements' ), "items_list_navigation" => __( "Elements list navigation", 'advanced-visual-elements' ), "items_list" => __( "Elements list", 'advanced-visual-elements' ), "attributes" => __( "Elements attributes", 'advanced-visual-elements' ), "name_admin_bar" => __( "Element", 'advanced-visual-elements' ), "item_published" => __( "Element published", 'advanced-visual-elements' ), "item_published_privately" => __( "Element published privately.", 'advanced-visual-elements' ), "item_reverted_to_draft" => __( "Element reverted to draft.", 'advanced-visual-elements' ), "item_scheduled" => __( "Element scheduled", 'advanced-visual-elements' ), "item_updated" => __( "Element updated.", 'advanced-visual-elements' ), "parent_item_colon" => __( "Parent Element:", 'advanced-visual-elements' ), ]; $args = [ "label" => __( "Elements", 'advanced-visual-elements' ), "labels" => $labels, "description" => "", "public" => false, "publicly_queryable" => false, "show_ui" => true, "show_in_rest" => false, "rest_base" => "", "rest_controller_class" => "WP_REST_Posts_Controller", "has_archive" => false, "show_in_menu" => false, "show_in_nav_menus" => false, "delete_with_user" => false, "exclude_from_search" => true, "capability_type" => "post", "map_meta_cap" => true, "hierarchical" => false, "rewrite" => false, "query_var" => true, "supports" => ["title"], ]; register_post_type( "adv-vis-element", $args ); remove_post_type_support( 'adv-vis-element', 'revisions' ); } /** * Options editing, after the post editor */ public function element_settings_editor() { global $post; $post_id = $post->ID; if ( $post->post_type != 'adv-vis-element' ) { return; } if ( isset( $_GET['element-id'] ) ) { // first time editing, redirected from the library $element_id = sanitize_text_field( $_GET['element-id'] ); } else { $element_id = get_post_meta( $post_id, 'adv-vis-ele-element_id', true ); } ?>
library->get_all_element_ids(); if ( empty( $installed ) ) { ?>
library->get_element( $element_id ); if ( !$element_info ) { echo '

' . __( 'Sorry, this Element does not exist anymore.', 'advanced-visual-elements' ) . '

'; echo '
'; return; } // update first time editing metas if ( isset( $_GET['element-id'] ) ) { update_post_meta( $post_id, 'adv-vis-ele-element_id', $element_id ); } ?> ' . __( 'You can only publish 3 Elements with Free version. ' . __( 'Buy Pro!', 'advanced-visual-elements' ) . '

', 'advanced-visual-elements' ) . __( 'Get updates, support, unlock unlimited number of Elements, all settings including dynamic content tags and more!', 'advanced-visual-elements' ) . ''; echo wp_kses_post( $go_pro_link ); ?>

settings ) ) { $meta_settings = Adv_Vis_Ele_Admin::get_element_meta_settings( $post_id ); foreach ( $element_info->settings as $setting ) { if ( $setting->type === 'boolean' ) { if ( isset( $meta_settings[$setting->id] ) ) { $setting->value = $meta_settings[$setting->id]; } else { $setting->value = $setting->default; } } else { if ( empty( $meta_settings[$setting->id] ) ) { if ( isset( $setting->default ) ) { $setting->value = $setting->default; } else { $setting->value = ''; } } else { $setting->value = $meta_settings[$setting->id]; } } echo '
'; if ( $setting->license !== 'free' && !wpave_fs()->is__premium_only() ) { $go_pro_link = '' . __( 'Buy Pro!', 'advanced-visual-elements' ) . ''; echo wp_kses_post( $go_pro_link ); } echo $this->library->render_setting_field( $setting ); echo '
'; // .adv-vis-ele-editor-setting } } $link = ADV_VIS_ELE_PLUGIN_WEBSITE . '/feedback'; ?>
!

? ? ">?

?

#adv-vis-ele-shortcode--
?
?
 px

settings as $setting ) { $element_settings_for_export[$setting->id] = $setting->value; } $element_settings_for_export = json_encode( $element_settings_for_export ); ?>
$dynamic_category ) { echo '

' . esc_html( $category_name ) . '

'; echo '
'; foreach ( $dynamic_category as $id => $name ) { echo '' . esc_html( $name ) . ''; if ( $category_name === 'Meta/ACF' ) { echo ''; echo '?'; $meta_keys = Adv_Vis_Ele_Helpers::get_all_meta_keys(); if ( !empty( $meta_keys ) ) { $meta_html = ''; foreach ( $meta_keys as $meta_key ) { if ( strpos( $meta_key, 'adv-vis-ele-' ) === 0 ) { continue; } $meta_html .= ''; } if ( !empty( $meta_html ) ) { echo '
'; echo ''; echo '
'; } } } } echo '
'; } ?>
'010', ] ); } $post_id = (int) $_POST['id']; $element_id = sanitize_text_field( $_POST['element-id'] ); $settings = []; foreach ( $_POST['settings'] as $key => $setting ) { $key = sanitize_text_field( $key ); if ( is_array( $setting ) ) { $settings[$key] = array_map( 'wp_kses_post', $setting ); } else { $settings[$key] = wp_kses_post( $setting ); } if ( $settings[$key] === 'true' ) { $settings[$key] = 'on'; } } if ( !$settings ) { wp_send_json_error( [ 'message' => __( "Couldn't properly decode options string.", 'advanced-visual-elements' ), ] ); } $redirection_url = ''; if ( get_post_status( $post_id ) === 'auto-draft' ) { wp_update_post( [ 'ID' => $post_id, 'post_status' => 'draft', 'post_title' => 'AVE Element ' . $post_id, ] ); $redirection_url = admin_url() . 'post.php?post=' . (int) $post_id . '&action=edit'; } if ( !empty( $settings ) && !empty( $post_id ) ) { $settings_element_id = $settings['adv-vis-ele-element_id']; if ( $element_id !== $settings_element_id ) { wp_send_json_error( [ 'message' => __( 'These options do not match the library Element. Try importing to a different shortcode.', 'advanced-visual-elements' ), ] ); } unset($settings['adv-vis-ele-element_id']); // remove the Element ID because we want only options $saving = $this->library->get_saving_settings( $settings, $element_id ); Adv_Vis_Ele_Admin::save_element_meta_settings( $saving, $post_id ); wp_send_json_success( [ 'redirection_url' => $redirection_url, 'message' => __( 'Options imported. Reloading the page...', 'advanced-visual-elements' ), ] ); } else { wp_send_json_error( [ 'message' => __( "Couldn't properly decode options string.", 'advanced-visual-elements' ), ] ); } } /** * Disable Gutenberg editor for WP AVE Elements */ public function disable_gutenberg( $current_status, $post_type ) { return $post_type !== 'adv-vis-element'; } /** * Delete library info when plugin is being updated, next time it loads it will fetch new info */ function delete_library_info( $upgrader_object, $options ) { if ( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) { update_option( 'adv_vis_ele_library_info_v2', [] ); } } }