home_url(), 'i18n' => [ 'rollback_confirm' => __( 'Are you sure you want to reinstall previous version?', 'elementor' ), 'rollback_to_previous_version' => __( 'Rollback to Previous Version', 'elementor' ), 'yes' => __( 'Yes', 'elementor' ), 'cancel' => __( 'Cancel', 'elementor' ), ], ] ); wp_enqueue_script( 'elementor-admin-app' ); if ( in_array( get_current_screen()->id, [ 'plugins', 'plugins-network' ] ) ) { add_action( 'admin_footer', [ $this, 'print_deactivate_feedback_dialog' ] ); $this->enqueue_feedback_dialog_scripts(); } } /** * Enqueue admin styles. * * Registers all the admin styles and enqueues them. * * Fired by `admin_enqueue_scripts` action. * * @since 1.0.0 * @access public */ public function enqueue_styles() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $direction_suffix = is_rtl() ? '-rtl' : ''; wp_register_style( 'elementor-icons', ELEMENTOR_ASSETS_URL . 'lib/eicons/css/elementor-icons' . $suffix . '.css', [], ELEMENTOR_VERSION ); wp_register_style( 'elementor-admin-app', ELEMENTOR_ASSETS_URL . 'css/admin' . $direction_suffix . $suffix . '.css', [ 'elementor-icons', ], ELEMENTOR_VERSION ); wp_enqueue_style( 'elementor-admin-app' ); // It's for upgrade notice. // TODO: enqueue this just if needed. add_thickbox(); } /** * Print switch mode button. * * Adds a switch button in post edit screen (which has cpt support). To allow * the user to switch from the native WordPress editor to Elementor builder. * * Fired by `edit_form_after_title` action. * * @since 1.0.0 * @access public * * @param \WP_Post $post The current post object. */ public function print_switch_mode_button( $post ) { if ( ! User::is_current_user_can_edit( $post->ID ) ) { return; } wp_nonce_field( basename( __FILE__ ), '_elementor_edit_mode_nonce' ); ?>
db->set_is_elementor_page( $post_id, ! empty( $_POST['_elementor_post_mode'] ) ); } /** * Add edit link in dashboard. * * Add an edit link to the post/page action links on the post/pages list table. * * Fired by `post_row_actions` and `page_row_actions` filters. * * @since 1.0.0 * @access public * * @param array $actions An array of row action links. * @param \WP_Post $post The post object. * * @return array An updated array of row action links. */ public function add_edit_in_dashboard( $actions, $post ) { if ( User::is_current_user_can_edit( $post->ID ) && Plugin::$instance->db->is_built_with_elementor( $post->ID ) ) { $actions['edit_with_elementor'] = sprintf( '%s', Utils::get_edit_link( $post->ID ), __( 'Edit with Elementor', 'elementor' ) ); } return $actions; } /** * Add Elementor post state. * * Adds a new "Elementor" post state to the post table. * * Fired by `display_post_states` filter. * * @since 1.8.0 * @access public * * @param array $post_states An array of post display states. * @param \WP_Post $post The current post object. * * @return array A filtered array of post display states. */ public function add_elementor_post_state( $post_states, $post ) { if ( User::is_current_user_can_edit( $post->ID ) && Plugin::$instance->db->is_built_with_elementor( $post->ID ) ) { $post_states['elementor'] = __( 'Elementor', 'elementor' ); } return $post_states; } /** * Body status classes. * * Adds CSS classes to the admin body tag. * * Fired by `admin_body_class` filter. * * @since 1.0.0 * @access public * * @param string $classes Space-separated list of CSS classes. * * @return string Space-separated list of CSS classes. */ public function body_status_classes( $classes ) { global $pagenow; if ( in_array( $pagenow, [ 'post.php', 'post-new.php' ] ) && Utils::is_post_type_support() ) { $post = get_post(); $mode_class = Plugin::$instance->db->is_built_with_elementor( $post->ID ) ? 'elementor-editor-active' : 'elementor-editor-inactive'; $classes .= ' ' . $mode_class; } return $classes; } /** * Plugin action links. * * Adds action links to the plugin list table * * Fired by `plugin_action_links` filter. * * @since 1.0.0 * @access public * * @param array $links An array of plugin action links. * * @return array An array of plugin action links. */ public function plugin_action_links( $links ) { $settings_link = sprintf( '%s', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), __( 'Settings', 'elementor' ) ); array_unshift( $links, $settings_link ); $links['go_pro'] = sprintf( '%s', Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-plugins&utm_campaign=gopro&utm_medium=wp-dash' ), __( 'Go Pro', 'elementor' ) ); return $links; } /** * Plugin row meta. * * Adds row meta links to the plugin list table * * Fired by `plugin_row_meta` filter. * * @since 1.1.4 * @access public * * @param array $plugin_meta An array of the plugin's metadata, including * the version, author, author URI, and plugin URI. * @param string $plugin_file Path to the plugin file, relative to the plugins * directory. * * @return array An array of plugin row meta links. */ public function plugin_row_meta( $plugin_meta, $plugin_file ) { if ( ELEMENTOR_PLUGIN_BASE === $plugin_file ) { $row_meta = [ 'docs' => '' . __( 'Docs & FAQs', 'elementor' ) . '', 'ideo' => '' . __( 'Video Tutorials', 'elementor' ) . '', ]; $plugin_meta = array_merge( $plugin_meta, $row_meta ); } return $plugin_meta; } /** * Admin notices. * * Add Elementor notices to WordPress admin screen. * * Fired by `admin_notices` action. * * @since 1.0.0 * @access public */ public function admin_notices() { $upgrade_notice = Api::get_upgrade_notice(); if ( empty( $upgrade_notice ) ) { return; } if ( ! current_user_can( 'update_plugins' ) ) { return; } if ( ! in_array( get_current_screen()->id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ] ) ) { return; } // Check if have any upgrades. $update_plugins = get_site_transient( 'update_plugins' ); if ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) ) { return; } $product = $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]; // Check if have upgrade notices to show. if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) { return; } $notice_id = 'upgrade_notice_' . $upgrade_notice['version']; if ( User::is_user_notice_viewed( $notice_id ) ) { return; } $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $product->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); $upgrade_url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . ELEMENTOR_PLUGIN_BASE ), 'upgrade-plugin_' . ELEMENTOR_PLUGIN_BASE ); ?>

View version %3$s details or update now.', 'elementor' ), esc_url( $details_url ), esc_attr( sprintf( /* translators: %s: Elementor version */ __( 'View Elementor version %s details', 'elementor' ), $product->new_version ) ), $product->new_version, esc_url( $upgrade_url ), esc_attr( __( 'Update Elementor Now', 'elementor' ) ) ); ?>

base, 'elementor' ) ); if ( $is_elementor_screen ) { $footer_text = sprintf( /* translators: %s: Link to plugin review */ __( 'Enjoyed Elementor? Please leave us a %s rating. We really appreciate your support!', 'elementor' ), '★★★★★' ); } return $footer_text; } /** * Enqueue feedback dialog scripts. * * Registers the feedback dialog scripts and enqueues them. * * @since 1.0.0 * @access public */ public function enqueue_feedback_dialog_scripts() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_register_script( 'elementor-admin-feedback', ELEMENTOR_ASSETS_URL . 'js/admin-feedback' . $suffix . '.js', [ 'jquery', 'underscore', 'elementor-dialog', ], ELEMENTOR_VERSION, true ); wp_enqueue_script( 'elementor-admin-feedback' ); wp_localize_script( 'elementor-admin-feedback', 'ElementorAdminFeedbackArgs', [ 'is_tracker_opted_in' => Tracker::is_allow_track(), 'i18n' => [ 'submit_n_deactivate' => __( 'Submit & Deactivate', 'elementor' ), 'skip_n_deactivate' => __( 'Skip & Deactivate', 'elementor' ), ], ] ); } /** * Print deactivate feedback dialog. * * Display a dialog box to ask the user why he deactivated Elementor. * * Fired by `admin_footer` filter. * * @since 1.0.0 * @access public */ public function print_deactivate_feedback_dialog() { $deactivate_reasons = [ 'no_longer_needed' => [ 'title' => __( 'I no longer need the plugin', 'elementor' ), 'input_placeholder' => '', ], 'found_a_better_plugin' => [ 'title' => __( 'I found a better plugin', 'elementor' ), 'input_placeholder' => __( 'Please share which plugin', 'elementor' ), ], 'couldnt_get_the_plugin_to_work' => [ 'title' => __( 'I couldn\'t get the plugin to work', 'elementor' ), 'input_placeholder' => '', ], 'temporary_deactivation' => [ 'title' => __( 'It\'s a temporary deactivation', 'elementor' ), 'input_placeholder' => '', ], 'other' => [ 'title' => __( 'Other', 'elementor' ), 'input_placeholder' => __( 'Please share the reason', 'elementor' ), ], ]; ?>
$reason ) : ?>
$dashboard['e-dashboard-overview'], ]; $wp_meta_boxes['dashboard']['normal']['core'] = array_merge( $ours, $dashboard ); } /** * Elementor dashboard widget. * * Displays the Elementor dashboard widget. * * Fired by `wp_add_dashboard_widget` function. * * @since 1.9.0 * @access public */ public function elementor_dashboard_overview_widget() { $elementor_feed = Api::get_feed_data(); $recently_edited_query_args = [ 'post_type' => 'any', 'posts_per_page' => '3', 'meta_key' => '_elementor_edit_mode', 'meta_value' => 'builder', 'orderby' => 'modified', ]; $recently_edited_query = new \WP_Query( $recently_edited_query_args ); ?>
v
have_posts() ) : ?>

[ 'title' => __( 'Blog', 'elementor' ), 'link' => 'https://go.elementor.com/overview-widget-blog/', ], 'help' => [ 'title' => __( 'Help', 'elementor' ), 'link' => 'https://go.elementor.com/overview-widget-docs/', ], ]; $additions_actions = [ 'go-pro' => [ 'title' => __( 'Go Pro', 'elementor' ), 'link' => Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-overview-widget&utm_campaign=gopro&utm_medium=wp-dash' ), ], ]; /** * Dashboard widget footer actions. * * Filters the additions actions displayed in Elementor dashboard widget. * * Developers can add new action links to Elementor dashboard widget * footer using this filter. * * @since 1.9.0 * * @param array $additions_actions Elementor dashboard widget footer actions. */ $additions_actions = apply_filters( 'elementor/admin/dashboard_overview_widget/footer_actions', $additions_actions ); $actions = $base_actions + $additions_actions; return $actions; } /** * @since 1.9.0 * @access public */ public function admin_action_new_post() { check_admin_referer( 'elementor_action_new_post' ); if ( empty( $_GET['post_type'] ) ) { $post_type = 'post'; } else { $post_type = $_GET['post_type']; } if ( ! User::is_current_user_can_edit_post_type( $post_type ) ) { return; } $post_data = [ 'post_type' => $post_type, 'post_title' => __( 'Elementor', 'elementor' ), ]; $post_id = wp_insert_post( $post_data ); $post_data['ID'] = $post_id; $post_data['post_title'] .= ' #' . $post_id; wp_update_post( $post_data ); wp_redirect( Utils::get_edit_link( $post_id ) ); die; } /** * Admin constructor. * * Initializing Elementor in WordPress admin. * * @since 1.0.0 * @access public */ public function __construct() { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] ); add_action( 'edit_form_after_title', [ $this, 'print_switch_mode_button' ] ); add_action( 'save_post', [ $this, 'save_post' ] ); add_filter( 'page_row_actions', [ $this, 'add_edit_in_dashboard' ], 10, 2 ); add_filter( 'post_row_actions', [ $this, 'add_edit_in_dashboard' ], 10, 2 ); add_filter( 'display_post_states', [ $this, 'add_elementor_post_state' ], 10, 2 ); add_filter( 'plugin_action_links_' . ELEMENTOR_PLUGIN_BASE, [ $this, 'plugin_action_links' ] ); add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); add_action( 'admin_notices', [ $this, 'admin_notices' ] ); add_filter( 'admin_body_class', [ $this, 'body_status_classes' ] ); add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ] ); // Register Dashboard Widgets. add_action( 'wp_dashboard_setup', [ $this, 'register_dashboard_widgets' ] ); // Ajax. add_action( 'wp_ajax_elementor_deactivate_feedback', [ $this, 'ajax_elementor_deactivate_feedback' ] ); // Admin Actions add_action( 'admin_action_elementor_new_post', [ $this, 'admin_action_new_post' ] ); } }