version = ADV_VIS_ELE_VERSION; } else { $this->version = '1.0.0'; } $this->plugin_name = 'wp-ave'; $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_install_element', $this->library, 'install_element'); $this->loader->add_action('wp_ajax_adv_vis_ele_ajax_uninstall_element', $this->library, 'uninstall_element'); $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_save_ordering', $this->library, 'ajax_save_ordering'); $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('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_action('admin_init', $this, 'update_library', 1); $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_preview_link_to_publish_box'); $this->loader->add_filter('wp_loaded', $plugin_admin, 'quick_preview'); $this->loader->add_action('current_screen', $plugin_admin, 'check_site_url', PHP_INT_MAX); $this->loader->add_action('init', $gutenberg_shortcode, 'gutenberg_shortcode_block'); 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, 'enqueue_styles'); $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_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", 'wp-ave'), "singular_name" => __("Element", 'wp-ave'), "menu_name" => __("My Elements", 'wp-ave'), "all_items" => __("All Elements", 'wp-ave'), "add_new" => __("Add new", 'wp-ave'), "add_new_item" => __("Add new Element", 'wp-ave'), "edit_item" => __("Edit Element", 'wp-ave'), "new_item" => __("New Element", 'wp-ave'), "view_item" => __("View Element", 'wp-ave'), "view_items" => __("View Elements", 'wp-ave'), "search_items" => __("Search Elements", 'wp-ave'), "not_found" => __("No Elements found", 'wp-ave'), "not_found_in_trash" => __("No Elements found in trash", 'wp-ave'), "parent" => __("Parent Element:", 'wp-ave'), "featured_image" => __("Featured image for this Element", 'wp-ave'), "set_featured_image" => __("Set featured image for this Element", 'wp-ave'), "remove_featured_image" => __("Remove featured image for this Element", 'wp-ave'), "use_featured_image" => __("Use as featured image for this Element", 'wp-ave'), "archives" => __("Element archives", 'wp-ave'), "insert_into_item" => __("Insert into Element", 'wp-ave'), "uploaded_to_this_item" => __("Upload to this Element", 'wp-ave'), "filter_items_list" => __("Filter Elements list", 'wp-ave'), "items_list_navigation" => __("Elements list navigation", 'wp-ave'), "items_list" => __("Elements list", 'wp-ave'), "attributes" => __("Elements attributes", 'wp-ave'), "name_admin_bar" => __("Element", 'wp-ave'), "item_published" => __("Element published", 'wp-ave'), "item_published_privately" => __("Element published privately.", 'wp-ave'), "item_reverted_to_draft" => __("Element reverted to draft.", 'wp-ave'), "item_scheduled" => __("Element scheduled", 'wp-ave'), "item_updated" => __("Element updated.", 'wp-ave'), "parent_item_colon" => __("Parent Element:", 'wp-ave') ]; $args = [ "label" => __("Elements", 'wp-ave'), "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_installed_elements(); if (empty($installed)) { ?>
library->get_element($element_id); if (!$element_info) { echo '

' . __('Sorry, this Element does not exist anymore.', 'wp-ave') . '

'; echo '
'; return; } // update first time editing metas if (isset($_GET['element-id'])) { update_post_meta($post_id, 'adv-vis-ele-element_id', $element_id); } if (!$this->library->is_element_installed($element_id)) { ?>
name) . '">' . __('This element will not work because it\'s not installed. Click here to install it now.', 'wp-ave') . ''; ?>

' . esc_html($element_info->name) . ''; ?>
[ave-element id=""]
<?php echo do_shortcode('[ave-element id=""]'); ?>

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()->can_use_premium_code()) { $go_pro_link = '' . __('Go Pro!', 'wp-ave') . ''; echo wp_kses_post($go_pro_link); } echo $this->library->render_setting_field($setting); echo '
'; // .adv-vis-ele-editor-setting } } ?>

?

#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); ?>

Export

Import

? ? ">?

$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 '
'; } ?>
library->update_library(); } } /** * Element editor AJAX options import */ public function ajax_import_settings() { $nonce_verified = isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'ave_ajax'); if (!$nonce_verified) { wp_send_json_error(['code' => '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.", 'wp-ave')]); } $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.', 'wp-ave')]); } 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...', 'wp-ave')]); } else { wp_send_json_error(['message' => __("Couldn't properly decode options string.", 'wp-ave')]); } } }