diff --git a/admin/assets/css/admin.css b/admin/assets/css/admin.css deleted file mode 100755 index 645830416..000000000 --- a/admin/assets/css/admin.css +++ /dev/null @@ -1,607 +0,0 @@ -/** - *============================================================= - * Essential Addons Elementor Admin Settings Page Styles - *============================================================= - */ - -/* General Style */ - -.eael-settings-wrap { - padding: 15px; -} -.eael-header-bar { - height: auto; - padding: 10px; - background: #fff; - border: 1px solid rgba( 0,0,0,0.1 ); - -webkit-display: flex; - display: flex; - -webkit-justify-content: flex-end; - justify-content: flex-end; - -webkit-align-items: center; - align-items: center; -} - -.eael-settings-wrap .eael-header-left { - display: flex; - align-content: center; - align-items: center; -} -.eael-header-bar .eael-admin-logo-inline { - width: 32px; - box-shadow: 1px 0 0 0 rgba(0,0,0,0.1); - padding: 10px 10px 5px; - margin-right: 10px; -} -.eael-header-bar .eael-admin-logo-inline img{ - width: 100%; -} -.eael-header-bar .title { - font-size: 24px; - color: #444; - font-weight: 600; - margin: 0px; - line-height: 1; -} - -.eael-header-left, -.eael-header-right { - -webkit-flex-grow: 1; - flex-grow: 1; -} -.eael-header-right { - text-align: right; -} -.eael-settings-tabs { - padding-top: 15px; -} - -.eael-settings-tab h4 { - font-size: 22px; -} - -.eael-settings-tab p { - font-size: 14px; -} - -.eael-settings-tabs ul { - width: 100%; - height: auto; - margin: 25px 0px 20px 0px; -} -.eael-settings-tabs ul li { - display: inline-block; -} -.eael-settings-tabs ul li a { - padding: 15px 20px; - background: #f8fafb; - color: #516378; - font-size: 15px; - font-weight: 600; - text-decoration: none; - border-top: 2px solid #f8fafb; -} -.eael-settings-tabs ul li:first-child a { - border-left: 1px solid rgba( 0,0,0,0.1 ) -} -.eael-settings-tabs ul li a:focus { - outline: none; - box-shadow: none; -} -.eael-settings-tabs ul li a img { - width: 20px; - margin: 0 5px -3px 0; -} -.eael-settings-tab { - background: #fff; - padding: 15px 25px; - margin-top: -8px; - border: 1px solid rgba( 0,0,0,0.1 ); - border-top: none; - position: relative; -} -.eael-settings-tabs ul li.ui-tabs-active a { - background: #fff; - outline: none; - box-shadow: none; - color: #343434; -} -p.eael-el-title { - font-size: 15px; - font-weight: 600; - color: #333; - margin: .5em; -} -.eael-settings-tab p.eael-elements-control-notice { - color: #42418e; - font-size: 16px; - border: 1px solid #42418e; - padding: 10px; - text-align: center; - display: block; -} -.eael-form-control { - width: 100%; -} -textarea.eael-form-control { - padding: 15px; - font-size: 14px; - font-weight: 600; - color: #5d5d5d; -} -.row { - width: 100%; - height: auto; - display: flex; - flex-flow: row wrap; - justify-content: space-between; - align-content: flex-start; - padding: 15px 0px; -} -.col-full { - width: 100%; - height: auto; -} -.col-half { - width: 49%; - height: auto; -} -.col-one-third { - width: 32%; - height: auto; -} -/* Checkbox Style */ - -.eael-checkbox-container { - display: flex; - flex-flow: row wrap; - align-items: center; -} -.eael-checkbox { - min-width: 250px; - font-size: 24px; - flex: 0 0 auto; - display: flex; - align-items: center; - margin: 10px; -} -.eael-checkbox input[type=checkbox] { - visibility: hidden; - display: none; -} -.eael-checkbox label { - width: 2em; - height: 1em; - position: relative; - cursor: pointer; - display: block; -} -.eael-checkbox label:before { - content: ''; - position: absolute; - width: 2em; - height: 1em; - left: 0.1em; - transition: background 0.1s 0.1s ease; - background: #CBCFD0; - border-radius: 50px; -} -.eael-checkbox label:after { - content: ''; - position: absolute; - width: .8em; - height: .8em; - border-radius: 100%; - left: .2em; - top: .1em; - transition: all 0.2s ease; - box-shadow: 0 0 0 5px #fcfff4 inset; - background: #CBCFD0; - z-index: 2; - animation: switch-off .3s ease-out; -} -.eael-checkbox input[type=checkbox]:checked + label:before { - background: #7E86F9; - box-shadow: inset 0px 1px 1px rgba(84, 152, 140, 0.5); -} -.eael-checkbox input[type=checkbox]:checked + label:after { - left: 1.2em; - background: #7E86F9; - animation: switch-on .3s ease-out; -} - -@keyframes switch-on { - 50% { - transform: scaleX(1.3); - } -} - -@keyframes switch-off { - 50% { - transform: scaleX(1.3); - } -} -/* Eael Tab Toggles */ -.eael-settings-tab { - display: none; -} -.eael-settings-tab.active { - display: block; -} -.eael-tabs li a.active { - background-color: #fff; - border-top: 2px solid #6648FE; -} -/* Footer Style */ - -.eael-settings-footer { - padding: 20px 25px 15px 25px; - background: #fff; - margin-top: 10px; - border: 1px solid rgba( 0,0,0,0.1 ); -} -.eael-settings-footer .submit { - padding: 0px; -} -.eael-settings-footer p.submit { - margin-top: 0px; -} - -.eael-settings-tab img { - max-width: 100%; -} -.button.eael-btn { - background-color: #0099CC; - color: #fff; - padding: 6px 20px; - border: none; - box-shadow: none; - font-size: 14px; - height: auto; - text-transform: uppercase; - text-shadow: none; - letter-spacing: .05em; -} - -.button.eael-btn:hover, .button.eael-btn:focus { - background-color: #1E96F1; - color: #fff; -} - -.eael-save-btn-wrap { - margin: 30px 0 20px; -} - -.eael-save-btn-wrap .eael-btn { - background-color: #3CCD94; - color: #fff; - padding: 10px 20px -} -.eael-save-btn-wrap .eael-btn:hover, .eael-save-btn-wrap .eael-btn:focus { - background-color: #02CC7B; - color: #fff; -} - -.eael-btn.eael-demo-btn { - background-color: #42418e; - color: #fff; -} -.eael-btn.eael-demo-btn:hover, .eael-btn.eael-demo-btn:focus { - background-color: #FF0188; - color: #fff; -} - - -.eael-btn.eael-license-btn { - background-color: #0dc9c3; -} -.eael-btn.eael-license-btn:hover, .eael-btn.eael-license-btn:focus { - background-color: #08d1ca; -} -.eael-btn.eael-demo-btn, .eael-btn.eael-license-btn, .eael-btn.eael-review-btn { - padding: 10px; - display: block; - max-width: 250px; - margin-bottom: 15px; - text-align: center; - font-size: 13px; -} -#eael-spinner { - width: 18px; - display: inline-block; - float: left; - margin: 3px 5px 0 0; - - -webkit-transition-property: -webkit-transform; - -webkit-transition-duration: 1.2s; - -webkit-animation-name: rotate; - -webkit-animation-iteration-count: infinite; - -webkit-animation-timing-function: linear; - - -moz-transition-property: -moz-transform; - -moz-animation-name: rotate; - -moz-animation-duration: 1.2s; - -moz-animation-iteration-count: infinite; - -moz-animation-timing-function: linear; - - transition-property: transform; - animation-name: rotate; - animation-duration: 1.2s; - animation-iteration-count: infinite; - animation-timing-function: linear; -} - -@-webkit-keyframes rotate { - from {-webkit-transform: rotate(0deg);} - to {-webkit-transform: rotate(360deg);} -} - -@-moz-keyframes rotate { - from {-moz-transform: rotate(0deg);} - to {-moz-transform: rotate(360deg);} -} - -@keyframes rotate { - from {transform: rotate(0deg);} - to {transform: rotate(360deg);} -} -.premium-elements-title { - margin: 50px 0 30px; -} - -.premium-elements-title img { - width: 75px; - float: left; -} - -.premium-elements-title .section-title { - color: #157EFB; - margin: 35px 5px 0; - text-transform: uppercase; - letter-spacing: 1px; - font-size: 20px; - border-bottom: 6px double #157EFB; - padding-bottom: 10px; - display: inline-block; -} - -.go-premium .eael-btn.eael-license-btn { - margin-top: 30px; -} - -.go-premium img { - width: 100%; - max-width: 400px; - display: block; - float: right; -} -.eael-notice { - background-color: #F7F6D4; - padding: 10px 15px; - border-radius: 5px; - box-shadow: 0 0 15px 0 rgba(0,0,0, .15); - max-width: 90%; - color: #9A7223; -} - -.eael-notice h5 { - font-size: 1.2em; - font-weight: bold; -} - -.essential-addons-community-link { - background-color: #475A96; - margin: 15px 0; - display: inline-block; - border-radius: 3px; -} - -.essential-addons-community-link:hover { - background-color: #3351b2; -} - -.essential-addons-community-link a { - color: #fff; - text-decoration: none; - padding: 15px 20px; - font-size: 1.4em; - display: flex; - align-items: center; - align-content: center; -} - -/* Header Button */ -.eael-header-bar .eael-btn { - background-color: #3CCD94; -} -.eael-header-bar .eael-btn:hover, .eael-header-bar .eael-btn:focus { - background-color: #02CC7B; -} -.eael-save-btn-wrap .eael-btn.save-now, -.eael-header-bar .eael-btn.save-now, -.eael-fb-feed-btn.save-now { - background: #E74C3C; -} -.eael-save-btn-wrap .eael-btn.save-now:hover, -.eael-header-bar .eael-btn.save-now:hover, -.eael-fb-feed-btn.save-now:hover { - background: #ff5544; -} - -/* Admin Blocks */ - -.eael-admin-general-wrapper { - width: 100%; - display: flex; - flex-flow: row wrap; - align-content: center; -} -.eael-admin-general-wrapper .eael-admin-general-inner { - max-width: 70em; - height: auto; - flex: 1 1 70%; -} -.eael-admin-general-wrapper .eael-sidebar { - flex: 1 1 200px; - padding: 20px; -} -.eael-admin-block-wrapper { - display: flex; - flex-flow: row wrap; - justify-content: space-between; - margin: -10px; -} -.eael-admin-block-wrapper .eael-admin-block { - background-color: #fff; - flex: 1 1 auto; - min-width: 250px; - width: 300px; - margin: 10px 10px 25px 10px; - box-shadow: 0 1px 4px rgba(0,0,0,0.1); -} -.eael-admin-block-large, -.eael-sidebar-widget { - background: #fff; - margin-bottom: 25px; - padding: 1em; - box-shadow: 0 1px 4px rgba(0,0,0,0.1); -} -.eael-admin-block-wrapper .eael-admin-block.eael-admin-block-banner { - padding: 8px; -} -.eael-admin-block-header { - max-height: 4em; - overflow: hidden; - border-bottom: 1px solid rgba(0,0,0,0.1); - background-color: #fff; - box-shadow: 0 1px 4px rgba(0,0,0,0.065); - display: flex; - align-content: center; - align-items: center; -} -.eael-admin-block-header-icon { - width: 42px; - box-shadow: 1px 0 0 0 rgba(0,0,0,0.1); - padding: 10px; -} -.eael-admin-block-header-icon svg { - width: 80%; - display: block; - margin: 0 auto; -} -.eael-admin-block-review .eael-admin-block-header-icon svg { - width: 100%; -} -.eael-admin-block-support .eael-admin-block-header-icon { - width: 30px; -} -.eael-settings-tab .eael-admin-title { - margin: 1em 0; - padding: 0 1.26582em; - font-size: 1.185em; - font-weight: 600; - text-overflow: ellipsis; - white-space: nowrap; -} -.eael-admin-block-content { - overflow: hidden; - position: relative; - padding: 1em 1.5em 1.5em; - background-color: #fff; -} -.eael-preview-img { - width: 100%; - height: 100%; - vertical-align: middle; - object-fit: cover; - transition: all .3s; -} -.eael-preview-img:hover{ - opacity: .9; -} - -.eael-admin-sidebar { - flex: 1 1 200px; - padding: 20px; -} -.eael-sidebar-block { - margin: calc(10% + 1.5em) auto; -} -.eael-sidebar-block .eael-admin-sidebar-logo { - max-width: 150px; - display: block; - margin: 0 auto; -} -.eael-sidebar-block .eael-admin-sidebar-logo > img, .eael-sidebar-block .eael-admin-sidebar-logo > svg { - width: 100%; - display: block; - margin: 10px auto; -} -.eael-admin-sidebar-cta a { - font-size: 1em; - color: rgba(35,40,45,0.45); - text-decoration: none; - text-transform: uppercase; - letter-spacing: .065em; - text-align: center; - margin: 20px auto; - display: block; - border: 1px solid rgba(35,40,45,0.185); - border-radius: 4px; - padding: 15px; - width: 200px; - outline: none; - box-shadow: none; - transition: all .3s; -} - -.eael-admin-sidebar-cta a:hover { - color: #23282d; - box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.715); -} - -/* Facebook Settings CSS */ - -#social-networks input { - padding: 10px; -} -#eaelFBbtn, #eaelFBbtnOwnApp { - cursor: pointer; - display: none; - /* color: red; */ - -} - -.page-list-with-access > ul { - list-style: none; -} -.page-list-with-access > ul > li { - display: block; - cursor: pointer; - padding: 5px 0px; -} -.eael-fb-own-app-settings { - display: none; -} -.eael-fb-own-app-settings.eael-active, #eaelFBbtn.eael-active, #eaelFBbtnOwnApp.eael-active { - display: block; -} - -.warning { - margin: 10px 0; - padding: 10px; - border-radius: 3px 3px 3px 3px; - color: #D8000C; - background-color: #FFBABA; - overflow: hidden; -} - -.warning > * { - float: left; -} -#eael_plugins_versions { - height: 36px; -} -.eael-notice-text { - padding-left: 10px; -} \ No newline at end of file diff --git a/admin/assets/css/eael-notice.css b/admin/assets/css/eael-notice.css deleted file mode 100755 index 2ec4f6391..000000000 --- a/admin/assets/css/eael-notice.css +++ /dev/null @@ -1,101 +0,0 @@ -/* review notice */ - -.wpdeveloper-review-notice { - padding: 10px; - background-color: #fff; - border-radius: 3px; - margin: 15px; - border-left: 4px solid transparent; - display: flex; - align-items: center; -} - -.wpdeveloper-review-notice:after { - content: ''; - display: table; - clear: both; -} - -.wpdeveloper-notice-thumbnail { - width: 90px; - float: left; - padding: 5px; - text-align: center; - border-right: 4px solid transparent; -} - -.wpdeveloper-notice-thumbnail img { - width: 72px; - opacity: .85; - transition: all .3s; -} - -.wpdeveloper-notice-thumbnail img:hover { - opacity: 1; -} - -.eael-review-text { - overflow: hidden; -} - -.eael-review-text h3 { - font-size: 24px; - margin: 0 0 5px; - font-weight: 400; - line-height: 1.3; -} - -.eael-review-text p { - font-size: 13px; - margin: 0 0 5px; -} - -.wpdeveloper-notice-link { - margin: 8px 0 0 0; - padding: 0; -} - -.wpdeveloper-notice-link li { - display: inline-block; - margin-right: 15px; -} - -.wpdeveloper-notice-link li a { - display: inline-block; - color: #10738B; - text-decoration: none; - padding-left: 26px; - position: relative; -} - -.wpdeveloper-notice-link li a span { - position: absolute; - left: 0; - top: -2px; -} - -.wpdeveloper-notice-message { - padding: 10px 0; -} -.wpdeveloper-upsale-notice .wpdeveloper-notice-message { - display: flex; - align-items: center; - padding: 10px 0; -} -.wpdeveloper-upsale-notice .wpdeveloper-notice-message + .notice-dismiss { - top: 18px; -} -.wpdeveloper-upsale-notice #plugin-install-core { - margin-left: 10px; -} -.notice.notice-has-thumbnail { - padding-left: 0px; -} - -.wpdeveloper-upsale-notice { - display: flex; -} -.wpdeveloper-upsale-notice .wpdeveloper-notice-thumbnail { - padding: 0; - width: 80px; -} \ No newline at end of file diff --git a/admin/assets/js/admin.js b/admin/assets/js/admin.js deleted file mode 100755 index f915d4c27..000000000 --- a/admin/assets/js/admin.js +++ /dev/null @@ -1,80 +0,0 @@ -( function( $ ) { - 'use strict'; - /** - * Eael Tabs - */ - $( '.eael-tabs li a' ).on( 'click', function(e) { - e.preventDefault(); - $( '.eael-tabs li a' ).removeClass( 'active' ); - $(this).addClass( 'active' ); - var tab = $(this).attr( 'href' ); - $( '.eael-settings-tab' ).removeClass( 'active' ); - $( '.eael-settings-tabs' ).find( tab ).addClass( 'active' ); - }); - - $( '.eael-get-pro' ).on( 'click', function() { - swal({ - title: '
', print_r( $response, 1 ), ''; - foreach( $response as $type ){ - $post_types[ $type->rest_base ] = $type->name; - } - $eael_exclude_cpts = array( 'elementor_library', 'media', 'product' ); - foreach ( $eael_exclude_cpts as $exclude_cpt ) { - unset($post_types[$exclude_cpt]); - } - // echo '
', print_r( $post_types, 1 ), ''; - echo json_encode( $post_types ); - - add_action( 'wp_ajax_save_facebook_feed_settings', array( $this, 'eael_save_facebook_feed_settings' ) ); - - } - - /** - * Loading all essential scripts - * @param - * @return void - * @since 1.1.2 - */ - public function enqueue_eael_admin_scripts( $hook ) { - wp_enqueue_style( 'essential_addons_elementor-notice-css', plugins_url( '/', __FILE__ ).'assets/css/eael-notice.css' ); - if( isset( $hook ) && $hook == 'plugins.php' ) { - wp_enqueue_style( 'essential_addons_elementor-sweetalert2-css', plugins_url( '/', __FILE__ ).'assets/vendor/sweetalert2/css/sweetalert2.min.css' ); - wp_enqueue_script( 'essential_addons_core-js', plugins_url( '/', __FILE__ ).'assets/vendor/sweetalert2/js/core.js', array( 'jquery' ), '1.0', true ); - wp_enqueue_script( 'essential_addons_sweetalert2-js', plugins_url( '/', __FILE__ ).'assets/vendor/sweetalert2/js/sweetalert2.min.js', array( 'jquery', 'essential_addons_core-js' ), '1.0', true ); - } - if( isset( $hook ) && $hook == 'elementor_page_eael-settings' ) { - wp_enqueue_style( 'essential_addons_elementor-admin-css', plugins_url( '/', __FILE__ ).'assets/css/admin.css' ); - wp_enqueue_style( 'essential_addons_elementor-sweetalert2-css', plugins_url( '/', __FILE__ ).'assets/vendor/sweetalert2/css/sweetalert2.min.css' ); - wp_enqueue_script( 'essential_addons_elementor-admin-js', plugins_url( '/', __FILE__ ).'assets/js/admin.js', array( 'jquery'), '1.0', true ); - wp_enqueue_script( 'essential_addons_core-js', plugins_url( '/', __FILE__ ).'assets/vendor/sweetalert2/js/core.js', array( 'jquery' ), '1.0', true ); - wp_enqueue_script( 'essential_addons_sweetalert2-js', plugins_url( '/', __FILE__ ).'assets/vendor/sweetalert2/js/sweetalert2.min.js', array( 'jquery', 'essential_addons_core-js' ), '1.0', true ); - } - - } - - /** - * Create an admin menu. - * @param - * @return void - * @since 1.1.2 - */ - public function create_eael_admin_menu() { - - add_submenu_page( - 'elementor', - 'Essential Addons', - 'Essential Addons', - 'manage_options', - 'eael-settings', - array( $this, 'eael_admin_settings_page' ) - ); - - } - - /** - * Create settings page. - * @param - * @return void - * @since 1.1.2 - */ - public function eael_admin_settings_page() { - - $js_info = array( - 'ajaxurl' => admin_url( 'admin-ajax.php' ) - ); - wp_localize_script( 'essential_addons_elementor-admin-js', 'js_eael_lite_settings', $js_info ); - - /** - * This section will handle the "eael_save_settings" array. If any new settings options is added - * then it will matches with the older array and then if it founds anything new then it will update the entire array. - */ - $this->eael_default_settings = array_fill_keys( $this->eael_default_keys, true ); - $this->eael_get_settings = get_option( 'eael_save_settings', $this->eael_default_settings ); - $eael_new_settings = array_diff_key( $this->eael_default_settings, $this->eael_get_settings ); - - if( ! empty( $eael_new_settings ) ) { - $eael_updated_settings = array_merge( $this->eael_get_settings, $eael_new_settings ); - update_option( 'eael_save_settings', $eael_updated_settings ); - } - $this->eael_get_settings = get_option( 'eael_save_settings', $this->eael_default_settings ); - ?> -
%1$s
%2$s' . __( 'Submitting form', 'plugin-usage-tracker' ) . '
'; - ?> - - - plugin_name, $values ); - } - if( isset( $_POST['details'] ) ) { - $details = sanitize_text_field( $_POST['details'] ); - update_option( 'wpins_deactivation_details_' . $this->plugin_name, $details ); - } - $this->do_tracking(); // Run this straightaway - echo 'success'; - wp_die(); - } - - } - -} \ No newline at end of file diff --git a/includes/class-wpdev-core-install.php b/includes/class-wpdev-core-install.php deleted file mode 100755 index 692974fae..000000000 --- a/includes/class-wpdev-core-install.php +++ /dev/null @@ -1,102 +0,0 @@ -plugin_basename = $plugin_basename; - add_action( 'init', array( $this, 'init_hooks' ) ); - } - /** - * Initialize the hooks - * - * @return void - */ - public function init_hooks() { - if ( ! current_user_can( 'manage_options' ) ) { - return; - } - add_action( 'wp_ajax_wpdeveloper_upsale_core_install_' . $this->plugin_basename, array( $this, 'core_install' ) ); - } - /** - * Fail if plugin installtion/activation fails - * - * @param Object $thing - * - * @return void - */ - public function fail_on_error( $thing ) { - if ( is_wp_error( $thing ) ) { - wp_send_json_error( $thing->get_error_message() ); - } - } - - /** - * Install Upsale Plugin - * - * @return void - */ - public function core_install() { - check_ajax_referer( 'wpdeveloper_upsale_core_install_' . $this->plugin_basename ); - - if ( ! current_user_can( 'manage_options' ) ) { - wp_send_json_error( __( 'You don\'t have permission to install the plugins' ) ); - } - - $plugin_slug = ( isset( $_POST['slug'] ) ) ? $_POST['slug'] : ''; - $plugin_file = ( isset( $_POST['file'] ) ) ? $_POST['file'] : ''; - - if( empty( $plugin_file ) || empty( $plugin_slug ) ) { - wp_send_json_error( __( 'You don\'t have set any slug and file name to install the plugins' ) ); - } - - $plugin_status = $this->install_plugin( $plugin_slug, $plugin_file ); - $this->fail_on_error( $plugin_status ); - - wp_send_json_success(); - } - /** - * Install and activate a plugin - * - * @param string $slug - * @param string $file - * - * @return WP_Error|null - */ - public function install_plugin( $slug, $file ) { - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - - $plugin_basename = $slug . '/' . $file; - - // if exists and not activated - if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_basename ) ) { - return activate_plugin( $plugin_basename ); - } - - // seems like the plugin doesn't exists. Download and activate it - $upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() ); - - $api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); - $result = $upgrader->install( $api->download_link ); - - if ( is_wp_error( $result ) ) { - return $result; - } - - return activate_plugin( $plugin_basename ); - } - } -endif; \ No newline at end of file diff --git a/includes/classes/Group_Control_EA_Posts.php b/includes/classes/Group_Control_EA_Posts.php new file mode 100755 index 000000000..bcd9b609d --- /dev/null +++ b/includes/classes/Group_Control_EA_Posts.php @@ -0,0 +1,150 @@ + __('Source', 'essential-addons-elementor'), + 'type' => Controls_Manager::SELECT, + ]; + + $fields['posts_ids'] = [ + 'label' => __('Search & Select', 'essential-addons-elementor'), + 'type' => Controls_Manager::SELECT2, + 'post_type' => '', + 'options' => $this->eael_get_all_types_post(), + 'label_block' => true, + 'multiple' => true, + 'condition' => [ + 'post_type' => 'by_id', + ], + ]; + + $fields['authors'] = [ + 'label' => __('Author', 'essential-addons-elementor'), + 'label_block' => true, + 'type' => Controls_Manager::SELECT2, + 'multiple' => true, + 'default' => [], + 'options' => $this->get_authors(), + 'condition' => [ + 'post_type!' => [ + 'by_id', + ], + ], + ]; + + return $fields; + } + + protected function prepare_fields($fields) + { + + $post_types = $this->eael_get_post_types(); + + $post_types_options = $post_types; + + $post_types_options['by_id'] = __('Manual Selection', 'essential-addons-elementor'); + + $fields['post_type']['options'] = $post_types_options; + + $fields['post_type']['default'] = key($post_types); + + $fields['posts_ids']['object_type'] = array_keys($post_types); + + $taxonomy_filter_args = [ + 'show_in_nav_menus' => true, + ]; + + if (!empty($args['post_type'])) { + $taxonomy_filter_args['object_type'] = [$args['post_type']]; + } + + $taxonomies = get_taxonomies($taxonomy_filter_args, 'objects'); + + foreach ($taxonomies as $taxonomy => $object) { + $taxonomy_args = [ + 'label' => $object->label, + 'type' => Controls_Manager::SELECT2, + 'label_block' => true, + 'multiple' => true, + 'object_type' => $taxonomy, + 'options' => [], + 'condition' => [ + 'post_type' => $object->object_type, + ], + ]; + + $options = []; + + $taxonomy_args['type'] = Controls_Manager::SELECT2; + + $terms = get_terms($taxonomy); + + foreach ($terms as $term) { + $options[$term->term_id] = $term->name; + } + + $taxonomy_args['options'] = $options; + + $fields[$taxonomy . '_ids'] = $taxonomy_args; + } + + unset($fields['post_format_ids']); + + return parent::prepare_fields($fields); + } + + /** + * All authors name and ID, who published at least 1 post. + * @return array + */ + public function get_authors() + { + $user_query = new \WP_User_Query( + [ + 'who' => 'authors', + 'has_published_posts' => true, + 'fields' => [ + 'ID', + 'display_name', + ], + ] + ); + + $authors = []; + + foreach ($user_query->get_results() as $result) { + $authors[$result->ID] = $result->display_name; + } + + return $authors; + } + + protected function get_default_options() + { + return [ + 'popover' => false, + ]; + } +} diff --git a/includes/classes/Plugin_Usage_Tracker.php b/includes/classes/Plugin_Usage_Tracker.php new file mode 100755 index 000000000..99cb9909e --- /dev/null +++ b/includes/classes/Plugin_Usage_Tracker.php @@ -0,0 +1,1063 @@ +plugin_file = $_plugin_file; + $this->home_url = trailingslashit($_home_url); + $this->plugin_name = basename($this->plugin_file, '.php'); + $this->options = $_options; + $this->require_optin = $_require_optin; + $this->include_goodbye_form = $_include_goodbye_form; + $this->marketing = $_marketing; + + // Schedule some tracking when activated + register_activation_hook($this->plugin_file, array($this, 'schedule_tracking')); + // Deactivation hook + register_deactivation_hook($this->plugin_file, array($this, 'deactivate_this_plugin')); + + // Get it going + $this->init(); + + } + /** + * Migrate to the new Insights + * @return void + */ + public function migrate_plan() + { + $old_key = array_flip(['wisdom_allow_tracking', 'wisdom_last_track_time', 'wisdom_block_notice', 'wisdom_collect_email', 'wisdom_admin_emails', 'wisdom_deactivation_reason_' . $this->plugin_name, 'wisdom_deactivation_details_' . $this->plugin_name]); + $new_key = ['wpins_allow_tracking', 'wpins_last_track_time', 'wpins_block_notice', 'wpins_collect_email', 'wpins_admin_emails', 'wpins_deactivation_reason_' . $this->plugin_name, 'wpins_deactivation_details_' . $this->plugin_name]; + + foreach ($old_key as $key => $value) { + $old_data = get_option($key); + if (!$old_data) { + continue; + } + update_option($new_key[$value], $old_data); + delete_option($key); + } + } + /** + * This function is fired for one time in a life time! + * if the data is not removed. + * @return void + */ + public function force_track_for_one_time() + { + $is_tracked = get_option('wpins_' . $this->plugin_name . '_force_tracked'); + if (!$is_tracked) { + $this->do_tracking(true); + update_option('wpins_' . $this->plugin_name . '_force_tracked', true); + } + } + + public function init() + { + if (version_compare($this->wpins_version, '1.1.2', '>')) { + $this->migrate_plan(); + } + // Check marketing + if ($this->marketing == 3) { + $this->set_can_collect_email(true, $this->plugin_name); + } + // Check whether opt-in is required + // If not, then tracking is allowed + if (!$this->require_optin) { + $this->set_can_collect_email(true, $this->plugin_name); + $this->set_is_tracking_allowed(true); + $this->update_block_notice(); + $this->do_tracking(true); + } + // Hook our do_tracking function to the daily action + add_action('wpdeveloper_notice_clicked_for_' . $this->plugin_name, array($this, 'clicked')); + + add_action('put_do_weekly_action', array($this, 'do_tracking')); + + // Use this action for local testing and for one time force tracking in a life time. + add_action('admin_init', array($this, 'force_track_for_one_time')); + // add_action( 'admin_init', array( $this, 'force_tracking' ) ); + + // Display the admin notice on activation + add_action('wpdeveloper_optin_notice_for_' . $this->plugin_name, array($this, 'optin_notice')); + add_action('admin_notices', array($this, 'marketing_notice')); + + // Deactivation + add_filter('plugin_action_links_' . plugin_basename($this->plugin_file), array($this, 'filter_action_links')); + add_action('admin_footer-plugins.php', array($this, 'goodbye_ajax')); + add_action('wp_ajax_goodbye_form_' . esc_attr($this->plugin_name), array($this, 'goodbye_form_callback')); + + } + + /** + * When the plugin is activated + * Create scheduled event + * And check if tracking is enabled - perhaps the plugin has been reactivated + * + * @since 1.0.0 + */ + public function schedule_tracking() + { + // For historical reasons, this is called 'weekly' but is in fact daily + if (!wp_next_scheduled('put_do_weekly_action')) { + wp_schedule_event(time(), 'daily', 'put_do_weekly_action'); + } + } + /** + * This function is responsible for force tracking the plugin, + * if users are allowed to do! + * + * @return void + */ + public function force_tracking() + { + $this->do_tracking(true); + } + + /** + * This is our function to get everything going + * Check that user has opted in + * Collect data + * Then send it back + * + * @since 1.0.0 + * @param $force Force tracking if it's not time + */ + public function do_tracking($force = false) + { + // If the home site hasn't been defined, we just drop out. Nothing much we can do. + if (!$this->home_url) { + return; + } + + // Check to see if the user has opted in to tracking + $allow_tracking = $this->get_is_tracking_allowed(); + if (!$allow_tracking) { + return; + } + + // Check to see if it's time to track + $track_time = $this->get_is_time_to_track(); + if (!$track_time && !$force) { + return; + } + + $this->set_admin_email(); + + // Get our data + $body = $this->get_data(); + + // Send the data + $this->send_data($body); + } + + /** + * Send the data to the home site + * + * @since 1.0.0 + */ + public function send_data($body) + { + + $request = wp_remote_post( + esc_url($this->home_url . '?usage_tracker=hello'), + array( + 'method' => 'POST', + 'timeout' => 20, + 'redirection' => 5, + 'httpversion' => '1.1', + 'blocking' => true, + 'body' => $body, + 'user-agent' => 'PUT/1.0.0; ' . get_bloginfo('url'), + ) + ); + + $this->set_track_time(); + + if (is_wp_error($request)) { + return $request; + } + + } + + /** + * Here we collect most of the data + * + * @since 1.0.0 + */ + public function get_data() + { + + // Use this to pass error messages back if necessary + $body['message'] = ''; + + // Use this array to send data back + $body = array( + 'plugin_slug' => sanitize_text_field($this->plugin_name), + 'url' => get_bloginfo('url'), + 'site_name' => get_bloginfo('name'), + 'site_version' => get_bloginfo('version'), + 'site_language' => get_bloginfo('language'), + 'charset' => get_bloginfo('charset'), + 'wpins_version' => $this->wpins_version, + 'php_version' => phpversion(), + 'multisite' => is_multisite(), + 'file_location' => __FILE__, + ); + + // Collect the email if the correct option has been set + if ($this->get_can_collect_email()) { + $body['email'] = $this->get_admin_email(); + } + $body['marketing_method'] = $this->marketing; + + $body['server'] = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : ''; + + // Retrieve current plugin information + if (!function_exists('get_plugins')) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + + $plugins = array_keys(get_plugins()); + $active_plugins = get_option('active_plugins', array()); + + foreach ($plugins as $key => $plugin) { + if (in_array($plugin, $active_plugins)) { + // Remove active plugins from list so we can show active and inactive separately + unset($plugins[$key]); + } + } + + $body['active_plugins'] = $active_plugins; + $body['inactive_plugins'] = $plugins; + + // Check text direction + $body['text_direction'] = 'LTR'; + if (function_exists('is_rtl')) { + if (is_rtl()) { + $body['text_direction'] = 'RTL'; + } + } else { + $body['text_direction'] = 'not set'; + } + + /** + * Get our plugin data + * Currently we grab plugin name and version + * Or, return a message if the plugin data is not available + * @since 1.0.0 + */ + $plugin = $this->plugin_data(); + if (empty($plugin)) { + // We can't find the plugin data + // Send a message back to our home site + $body['message'] .= __('We can\'t detect any plugin information. This is most probably because you have not included the code in the plugin main file.', 'plugin-usage-tracker'); + $body['status'] = 'Data not found'; // Never translated + } else { + if (isset($plugin['Name'])) { + $body['plugin'] = sanitize_text_field($plugin['Name']); + } + if (isset($plugin['Version'])) { + $body['version'] = sanitize_text_field($plugin['Version']); + } + $body['status'] = 'Active'; // Never translated + } + + /** + * Get our plugin options + * @since 1.0.0 + */ + $options = $this->options; + $plugin_options = array(); + if (!empty($options) && is_array($options)) { + foreach ($options as $option) { + $fields = get_option($option); + // Check for permission to send this option + if (isset($fields['wpins_registered_setting'])) { + foreach ($fields as $key => $value) { + $plugin_options[$key] = $value; + } + } + } + } + $body['plugin_options'] = $this->options; // Returns array + $body['plugin_options_fields'] = $plugin_options; // Returns object + + /** + * Get our theme data + * Currently we grab theme name and version + * @since 1.0.0 + */ + $theme = wp_get_theme(); + if ($theme->Name) { + $body['theme'] = sanitize_text_field($theme->Name); + } + if ($theme->Version) { + $body['theme_version'] = sanitize_text_field($theme->Version); + } + + // Return the data + return $body; + + } + + /** + * Return plugin data + * @since 1.0.0 + */ + public function plugin_data() + { + // Being cautious here + if (!function_exists('get_plugin_data')) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + // Retrieve current plugin information + $plugin = get_plugin_data($this->plugin_file); + return $plugin; + } + + /** + * Deactivating plugin + * @since 1.0.0 + */ + public function deactivate_this_plugin() + { + // Check to see if the user has opted in to tracking + $allow_tracking = $this->get_is_tracking_allowed(); + if (!$allow_tracking) { + return; + } + $body = $this->get_data(); + $body['status'] = 'Deactivated'; // Never translated + $body['deactivated_date'] = time(); + + // Add deactivation form data + if (false !== get_option('wpins_deactivation_reason_' . $this->plugin_name)) { + $body['deactivation_reason'] = get_option('wpins_deactivation_reason_' . $this->plugin_name); + } + if (false !== get_option('wpins_deactivation_details_' . $this->plugin_name)) { + $body['deactivation_details'] = get_option('wpins_deactivation_details_' . $this->plugin_name); + } + + $this->send_data($body); + // Clear scheduled update + wp_clear_scheduled_hook('put_do_weekly_action'); + } + + /** + * Is tracking allowed? + * @since 1.0.0 + */ + public function get_is_tracking_allowed() + { + // First, check if the user has changed their mind and opted out of tracking + if ($this->has_user_opted_out()) { + $this->set_is_tracking_allowed(false, $this->plugin_name); + return false; + } + // The wpins_allow_tracking option is an array of plugins that are being tracked + $allow_tracking = get_option('wpins_allow_tracking'); + // If this plugin is in the array, then tracking is allowed + if (isset($allow_tracking[$this->plugin_name])) { + return true; + } + return false; + } + + /** + * Set if tracking is allowed + * Option is an array of all plugins with tracking permitted + * More than one plugin may be using the tracker + * @since 1.0.0 + * @param $is_allowed Boolean true if tracking is allowed, false if not + */ + public function set_is_tracking_allowed($is_allowed, $plugin = null) + { + if (empty($plugin)) { + $plugin = $this->plugin_name; + } + // The wpins_allow_tracking option is an array of plugins that are being tracked + $allow_tracking = get_option('wpins_allow_tracking'); + + // If the user has decided to opt out + if ($this->has_user_opted_out()) { + if (isset($allow_tracking[$plugin])) { + unset($allow_tracking[$plugin]); + } + } else if ($is_allowed || !$this->require_optin) { + // If the user has agreed to allow tracking or if opt-in is not required + if (empty($allow_tracking) || !is_array($allow_tracking)) { + // If nothing exists in the option yet, start a new array with the plugin name + $allow_tracking = array($plugin => $plugin); + } else { + // Else add the plugin name to the array + $allow_tracking[$plugin] = $plugin; + } + } else { + if (isset($allow_tracking[$plugin])) { + unset($allow_tracking[$plugin]); + } + } + update_option('wpins_allow_tracking', $allow_tracking); + } + + /** + * Has the user opted out of allowing tracking? + * @since 1.1.0 + * @return Boolean + */ + public function has_user_opted_out() + { + // Iterate through the options that are being tracked looking for wpins_opt_out setting + if (!empty($this->options)) { + foreach ($this->options as $option_name) { + // Check each option + $options = get_option($option_name); + // If we find the setting, return true + if (!empty($options['wpins_opt_out'])) { + return true; + } + } + } + return false; + } + + /** + * Check if it's time to track + * @since 1.1.1 + */ + public function get_is_time_to_track() + { + // Let's see if we're due to track this plugin yet + $track_times = get_option('wpins_last_track_time', array()); + if (!isset($track_times[$this->plugin_name])) { + // If we haven't set a time for this plugin yet, then we must track it + return true; + } else { + // If the time is set, let's see if it's more than a day ago + if ($track_times[$this->plugin_name] < strtotime('-1 day')) { + return true; + } + } + return false; + } + + /** + * Record the time we send tracking data + * @since 1.1.1 + */ + public function set_track_time() + { + // We've tracked, so record the time + $track_times = get_option('wpins_last_track_time', array()); + // Set different times according to plugin, in case we are tracking multiple plugins + $track_times[$this->plugin_name] = time(); + update_option('wpins_last_track_time', $track_times); + } + + /** + * Set if we should block the opt-in notice for this plugin + * Option is an array of all plugins that have received a response from the user + * @since 1.0.0 + */ + public function update_block_notice($plugin = null) + { + if (empty($plugin)) { + $plugin = $this->plugin_name; + } + $block_notice = get_option('wpins_block_notice'); + if (empty($block_notice) || !is_array($block_notice)) { + // If nothing exists in the option yet, start a new array with the plugin name + $block_notice = array($plugin => $plugin); + } else { + // Else add the plugin name to the array + $block_notice[$plugin] = $plugin; + } + update_option('wpins_block_notice', $block_notice); + } + + /** + * Can we collect the email address? + * @since 1.0.0 + */ + public function get_can_collect_email() + { + // The wpins_collect_email option is an array of plugins that are being tracked + $collect_email = get_option('wpins_collect_email'); + // If this plugin is in the array, then we can collect the email address + if (isset($collect_email[$this->plugin_name])) { + return true; + } + return false; + } + + /** + * Set if user has allowed us to collect their email address + * Option is an array of all plugins with email collection permitted + * More than one plugin may be using the tracker + * @since 1.0.0 + * @param $can_collect Boolean true if collection is allowed, false if not + */ + public function set_can_collect_email($can_collect, $plugin = null) + { + if (empty($plugin)) { + $plugin = $this->plugin_name; + } + // The wpins_collect_email option is an array of plugins that are being tracked + $collect_email = get_option('wpins_collect_email'); + // If the user has agreed to allow tracking or if opt-in is not required + if ($can_collect) { + if (empty($collect_email) || !is_array($collect_email)) { + // If nothing exists in the option yet, start a new array with the plugin name + $collect_email = array($plugin => $plugin); + } else { + // Else add the plugin name to the array + $collect_email[$plugin] = $plugin; + } + } else { + if (isset($collect_email[$plugin])) { + unset($collect_email[$plugin]); + } + } + update_option('wpins_collect_email', $collect_email); + } + + /** + * Get the correct email address to use + * @since 1.1.2 + * @return Email address + */ + public function get_admin_email() + { + // The wpins_collect_email option is an array of plugins that are being tracked + $email = get_option('wpins_admin_emails'); + // If this plugin is in the array, then we can collect the email address + if (isset($email[$this->plugin_name])) { + return $email[$this->plugin_name]; + } + return false; + } + + /** + * Set the correct email address to use + * There might be more than one admin on the site + * So we only use the first admin's email address + * @param $email Email address to set + * @param $plugin Plugin name to set email address for + * @since 1.1.2 + */ + public function set_admin_email($email = null, $plugin = null) + { + if (empty($plugin)) { + $plugin = $this->plugin_name; + } + // If no email address passed, try to get the current user's email + if (empty($email)) { + // Have to check that current user object is available + if (function_exists('wp_get_current_user')) { + $current_user = wp_get_current_user(); + $email = $current_user->user_email; + } + } + // The wpins_admin_emails option is an array of admin email addresses + $admin_emails = get_option('wpins_admin_emails'); + if (empty($admin_emails) || !is_array($admin_emails)) { + // If nothing exists in the option yet, start a new array with the plugin name + $admin_emails = array($plugin => sanitize_email($email)); + } else if (empty($admin_emails[$plugin])) { + // Else add the email address to the array, if not already set + $admin_emails[$plugin] = sanitize_email($email); + } + update_option('wpins_admin_emails', $admin_emails); + } + + public function clicked() + { + // Check for plugin args + if (isset($_GET['plugin']) && isset($_GET['plugin_action'])) { + $plugin = sanitize_text_field($_GET['plugin']); + $action = sanitize_text_field($_GET['plugin_action']); + if ($action == 'yes') { + $this->set_is_tracking_allowed(true, $plugin); + $this->do_tracking(true); // Run this straightaway + } else { + $this->set_is_tracking_allowed(false, $plugin); + } + $this->update_block_notice($plugin); + } + } + + /** + * Display the admin notice to users to allow them to opt in + * + * @since 1.0.0 + */ + public function optin_notice() + { + // Check whether to block the notice, e.g. because we're in a local environment + // wpins_block_notice works the same as wpins_allow_tracking, an array of plugin names + $block_notice = get_option('wpins_block_notice'); + if (isset($block_notice[$this->plugin_name])) { + return; + } + + if (!current_user_can('manage_options')) { + return; + } + + // @credit EDD + // Don't bother asking user to opt in if they're in local dev + $is_local = false; + if (stristr(network_site_url('/'), '.dev') !== false || stristr(network_site_url('/'), 'localhost') !== false || stristr(network_site_url('/'), ':8888') !== false) { + $is_local = true; + } + $is_local = apply_filters('wpins_is_local_' . $this->plugin_name, $is_local); + if ($is_local) { + $this->update_block_notice(); + } else { + + // Display the notice requesting permission to track + // Retrieve current plugin information + $plugin = $this->plugin_data(); + $plugin_name = $plugin['Name']; + + // Args to add to query if user opts in to tracking + $yes_args = array( + 'plugin' => $this->plugin_name, + 'plugin_action' => 'yes', + ); + + // Decide how to request permission to collect email addresses + if ($this->marketing == 1) { + // Option 1 combines permissions to track and collect email + $yes_args['marketing_optin'] = 'yes'; + } else if ($this->marketing == 2) { + // Option 2 enables a second notice that fires after the user opts in to tracking + $yes_args['marketing'] = 'yes'; + } + $url_yes = add_query_arg($yes_args); + $url_no = add_query_arg(array( + 'plugin' => $this->plugin_name, + 'plugin_action' => 'no', + )); + + // Decide on notice text + if ($this->marketing != 1) { + // Standard notice text + $notice_text = __('Thank you for installing our plugin. We would like to track its usage on your site. We don\'t record any sensitive data, only information regarding the WordPress environment and plugin settings, which we will use to help us make improvements to the plugin. Tracking is completely optional.', 'plugin-usage-tracker'); + } else { + // If we have option 1 for marketing, we include reference to sending product information here + $notice_text = __('Want to help make Essential Addons for Elementor even more awesome? You can get a 25% discount coupon for Pro upgrade if you allow. What we collect.', 'plugin-usage-tracker'); + } + // And we allow you to filter the text anyway + $notice_text = apply_filters('wpins_notice_text_' . esc_attr($this->plugin_name), $notice_text);?> + +' . __('Submitting form', 'plugin-usage-tracker') . '
'; + ?> + + + plugin_name, $values); + } + if (isset($_POST['details'])) { + $details = sanitize_text_field($_POST['details']); + update_option('wpins_deactivation_details_' . $this->plugin_name, $details); + } + $this->do_tracking(); // Run this straightaway + echo 'success'; + wp_die(); + } + +} \ No newline at end of file diff --git a/includes/classes/WPDeveloper_Core_Installer.php b/includes/classes/WPDeveloper_Core_Installer.php new file mode 100755 index 000000000..9b22e1351 --- /dev/null +++ b/includes/classes/WPDeveloper_Core_Installer.php @@ -0,0 +1,106 @@ +plugin_basename = $plugin_basename; + add_action( 'init', array( $this, 'init_hooks' ) ); + } + /** + * Initialize the hooks + * + * @return void + */ + public function init_hooks() { + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + add_action( 'wp_ajax_wpdeveloper_upsale_core_install_' . $this->plugin_basename, array( $this, 'core_install' ) ); + } + /** + * Fail if plugin installtion/activation fails + * + * @param Object $thing + * + * @return void + */ + public function fail_on_error( $thing ) { + if ( is_wp_error( $thing ) ) { + wp_send_json_error( $thing->get_error_message() ); + } + } + + /** + * Install Upsale Plugin + * + * @return void + */ + public function core_install() { + check_ajax_referer( 'wpdeveloper_upsale_core_install_' . $this->plugin_basename ); + + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( __( 'You don\'t have permission to install the plugins' ) ); + } + + $plugin_slug = ( isset( $_POST['slug'] ) ) ? $_POST['slug'] : ''; + $plugin_file = ( isset( $_POST['file'] ) ) ? $_POST['file'] : ''; + + if( empty( $plugin_file ) || empty( $plugin_slug ) ) { + wp_send_json_error( __( 'You don\'t have set any slug and file name to install the plugins' ) ); + } + + $plugin_status = $this->install_plugin( $plugin_slug, $plugin_file ); + $this->fail_on_error( $plugin_status ); + + wp_send_json_success(); + } + /** + * Install and activate a plugin + * + * @param string $slug + * @param string $file + * + * @return WP_Error|null + */ + public function install_plugin( $slug, $file ) { + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + + $plugin_basename = $slug . '/' . $file; + + // if exists and not activated + if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_basename ) ) { + return activate_plugin( $plugin_basename ); + } + + // seems like the plugin doesn't exists. Download and activate it + $upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() ); + + $api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); + $result = $upgrader->install( $api->download_link ); + + if ( is_wp_error( $result ) ) { + return $result; + } + + return activate_plugin( $plugin_basename ); + } +} \ No newline at end of file diff --git a/includes/class-wpdev-notices.php b/includes/classes/WPDeveloper_Notice.php similarity index 91% rename from includes/class-wpdev-notices.php rename to includes/classes/WPDeveloper_Notice.php index bc8c89a6f..8f99084a1 100755 --- a/includes/class-wpdev-notices.php +++ b/includes/classes/WPDeveloper_Notice.php @@ -1,4 +1,12 @@ do_notice_action = 'wpdeveloper_notices_for_' . $this->plugin_name; - if( ! class_exists( 'WPDeveloper_Core_Installer' ) ) { - require_once dirname( __FILE__ ) . '/class-wpdev-core-install.php'; - - new WPDeveloper_Core_Installer( $this->plugin_name ); - } + new WPDeveloper_Core_Installer( $this->plugin_name ); } /** * Initiate The Plugin @@ -776,7 +780,7 @@ public function upsale_button_script(){ dismiss: true }, success: function(response) { - console.log('Success fully saved!'); + console.log('Successfully saved!'); }, error: function(error) { console.log('Something went wrong!'); @@ -791,76 +795,4 @@ public function upsale_button_script(){ links = [ - 'review' => array( - 'later' => array( - 'link' => 'https://wpdeveloper.net/review-essential-addons-elementor', - 'target' => '_blank', - 'label' => __( 'Ok, you deserve it!', 'essential-addons-elementor' ), - 'icon_class' => 'dashicons dashicons-external', - ), - 'allready' => array( - 'link' => $url, - 'label' => __( 'I already did', 'essential-addons-elementor' ), - 'icon_class' => 'dashicons dashicons-smiley', - 'data_args' => [ - 'dismiss' => true, - ] - ), - 'maybe_later' => array( - 'link' => $url, - 'label' => __( 'Maybe Later', 'essential-addons-elementor' ), - 'icon_class' => 'dashicons dashicons-calendar-alt', - 'data_args' => [ - 'later' => true, - ] - ), - 'support' => array( - 'link' => 'https://wpdeveloper.net/support', - 'label' => __( 'I need help', 'essential-addons-elementor' ), - 'icon_class' => 'dashicons dashicons-sos', - ), - 'never_show_again' => array( - 'link' => $url, - 'label' => __( 'Never show again', 'essential-addons-elementor' ), - 'icon_class' => 'dashicons dashicons-dismiss', - 'data_args' => [ - 'dismiss' => true, - ] - ), - ) -]; - -/** - * This is review message and thumbnail. - */ -$notice->message( 'review', ''. __( 'We hope you\'re enjoying Essential Addons for Elementor! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'essential-addons-elementor' ) .'
' ); -$notice->thumbnail( 'review', plugins_url( 'admin/assets/images/ea-logo.svg', ESSENTIAL_ADDONS_BASENAME ) ); - -/** - * Current Notice End Time. - * Notice will dismiss in 3 days if user does nothing. - */ -$notice->cne_time = '3 Day'; -/** - * Current Notice Maybe Later Time. - * Notice will show again in 7 days - */ -$notice->maybe_later_time = '7 Day'; - -$notice->text_domain = 'essential-addons-elementor'; - -$notice->options_args = array( - 'notice_will_show' => [ - 'opt_in' => $notice->timestamp, - 'review' => $notice->makeTime( $notice->timestamp, '4 Day' ), // after 4 days - ] -); - -$notice->init(); \ No newline at end of file +} \ No newline at end of file diff --git a/includes/eae-posts-group-control.php b/includes/eae-posts-group-control.php deleted file mode 100755 index 9573f453f..000000000 --- a/includes/eae-posts-group-control.php +++ /dev/null @@ -1,145 +0,0 @@ - __( 'Source', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT, - ]; - - $fields['posts_ids'] = [ - 'label' => __( 'Search & Select', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT2, - 'post_type' => '', - 'options' => \eael_get_all_types_post(), - 'label_block' => true, - 'multiple' => true, - 'condition' => [ - 'post_type' => 'by_id', - ], - ]; - - $fields['authors'] = [ - 'label' => __( 'Author', 'essential-addons-elementor' ), - 'label_block' => true, - 'type' => Controls_Manager::SELECT2, - 'multiple' => true, - 'default' => [], - 'options' => $this->get_authors(), - 'condition' => [ - 'post_type!' => [ - 'by_id', - ], - ], - ]; - - return $fields; - } - - protected function prepare_fields( $fields ) { - - $post_types = eael_get_post_types(); - - $post_types_options = $post_types; - - $post_types_options['by_id'] = __( 'Manual Selection', 'essential-addons-elementor' ); - - $fields['post_type']['options'] = $post_types_options; - - $fields['post_type']['default'] = key( $post_types ); - - $fields['posts_ids']['object_type'] = array_keys( $post_types ); - - $taxonomy_filter_args = [ - 'show_in_nav_menus' => true, - ]; - - if ( ! empty( $args['post_type'] ) ) { - $taxonomy_filter_args['object_type'] = [ $args['post_type'] ]; - } - - $taxonomies = get_taxonomies( $taxonomy_filter_args, 'objects' ); - - foreach ( $taxonomies as $taxonomy => $object ) { - $taxonomy_args = [ - 'label' => $object->label, - 'type' => Controls_Manager::SELECT2, - 'label_block' => true, - 'multiple' => true, - 'object_type' => $taxonomy, - 'options' => [], - 'condition' => [ - 'post_type' => $object->object_type, - ], - ]; - - $options = []; - - $taxonomy_args['type'] = Controls_Manager::SELECT2; - - $terms = get_terms( $taxonomy ); - - foreach ( $terms as $term ) { - $options[ $term->term_id ] = $term->name; - } - - $taxonomy_args['options'] = $options; - - $fields[ $taxonomy . '_ids' ] = $taxonomy_args; - } - - unset( $fields['post_format_ids'] ); - - return parent::prepare_fields( $fields ); - } - - /** - * All authors name and ID, who published at least 1 post. - * @return array - */ - public function get_authors() { - $user_query = new \WP_User_Query( - [ - 'who' => 'authors', - 'has_published_posts' => true, - 'fields' => [ - 'ID', - 'display_name', - ], - ] - ); - - $authors = []; - - foreach ( $user_query->get_results() as $result ) { - $authors[ $result->ID ] = $result->display_name; - } - - return $authors; - } - - protected function get_default_options() { - return [ - 'popover' => false, - ]; - } - } -endif; \ No newline at end of file diff --git a/includes/elementor-helper.php b/includes/elementor-helper.php deleted file mode 100755 index 8ca9387f2..000000000 --- a/includes/elementor-helper.php +++ /dev/null @@ -1,766 +0,0 @@ -elements_manager->add_category( - 'essential-addons-elementor', - [ - 'title' => 'Essential Addons', - 'icon' => 'font' - ], - 1 - ); - - /** - * Initialize EAE_Helper - */ - new EAE_Helper; - -} -add_action('elementor/init','Elementor\eael_elementor_init'); - - -trait ElementsCommonFunctions { - - /** - * For Exclude Option - */ - public function add_exclude_controls( ) { - $this->add_control( - 'post__not_in', - [ - 'label' => __( 'Exclude', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT2, - 'options' => eael_get_all_types_post(), - 'label_block' => true, - 'post_type' => '', - 'multiple' => true, - 'condition' => [ - 'eaeposts_post_type!' => 'by_id' - ], - ] - ); - } - - protected function query_controls(){ - - if( 'eael-content-ticker' === $this->get_name() ) { - $this->start_controls_section( - 'eael_section_content_ticker_filters', - [ - 'label' => __( 'Dynamic Content Settings', 'essential-addons-elementor' ), - 'condition' => [ - 'eael_ticker_type' => 'dynamic' - ] - ] - ); - } - - if( 'eael-content-timeline' === $this->get_name() ) { - $this->start_controls_section( - 'eael_section_timeline__filters', - [ - 'label' => __( 'Dynamic Content Settings', 'essential-addons-elementor' ), - 'condition' => [ - 'eael_content_timeline_choose' => 'dynamic' - ] - ] - ); - } - - if( 'eael-content-timeline' !== $this->get_name() && 'eael-content-ticker' !== $this->get_name() ) { - $this->start_controls_section( - 'eael_section_post__filters', - [ - 'label' => __( 'Query', 'essential-addons-elementor' ), - ] - ); - } - - $this->add_group_control( - EAE_Posts_Group_Control::get_type(), - [ - 'name' => 'eaeposts' - ] - ); - - $this->add_exclude_controls(); - - $this->add_control( - 'posts_per_page', - [ - 'label' => __( 'Posts Per Page', 'essential-addons-elementor' ), - 'type' => Controls_Manager::NUMBER, - 'default' => '4' - ] - ); - - $this->add_control( - 'offset', - [ - 'label' => __( 'Offset', 'essential-addons-elementor' ), - 'type' => Controls_Manager::NUMBER, - 'default' => '0' - ] - ); - - $this->add_control( - 'orderby', - [ - 'label' => __( 'Order By', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT, - 'options' => eael_get_post_orderby_options(), - 'default' => 'date', - - ] - ); - - $this->add_control( - 'order', - [ - 'label' => __( 'Order', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT, - 'options' => [ - 'asc' => 'Ascending', - 'desc' => 'Descending' - ], - 'default' => 'desc', - - ] - ); - - $this->end_controls_section(); - - } - - /** - * Go Premium - */ - protected function eae_go_premium(){ - $this->start_controls_section( - 'eael_section_pro', - [ - 'label' => __( 'Go Premium for More Features', 'essential-addons-elementor' ) - ] - ); - - $this->add_control( - 'eael_control_get_pro', - [ - 'label' => __( 'Unlock more possibilities', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( '', 'essential-addons-elementor' ), - 'icon' => 'fa fa-unlock-alt', - ], - ], - 'default' => '1', - 'description' => ' Get the Pro version for more stunning elements and customization options.' - ] - ); - - $this->end_controls_section(); - } - - - /** - * Layout Controls For All Post Block! - * if needed! - */ - protected function layout_controls(){ - - $this->start_controls_section( - 'eael_section_post_timeline_layout', - [ - 'label' => __( 'Layout Settings', 'essential-addons-elementor' ) - ] - ); - - if( 'eael-post-grid' === $this->get_name() ) { - $this->add_control( - 'eael_post_grid_columns', - [ - 'label' => esc_html__( 'Number of Columns', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT, - 'default' => 'eael-col-4', - 'options' => [ - 'eael-col-1' => esc_html__( 'Single Column', 'essential-addons-elementor' ), - 'eael-col-2' => esc_html__( 'Two Columns', 'essential-addons-elementor' ), - 'eael-col-3' => esc_html__( 'Three Columns', 'essential-addons-elementor' ), - 'eael-col-4' => esc_html__( 'Four Columns', 'essential-addons-elementor' ), - 'eael-col-5' => esc_html__( 'Five Columns', 'essential-addons-elementor' ), - 'eael-col-6' => esc_html__( 'Six Columns', 'essential-addons-elementor' ), - ], - ] - ); - } - - if( 'eael-post-block' === $this->get_name() ) { - $this->add_control( - 'grid_style', - [ - 'label' => esc_html__( 'Post Block Style Preset', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT, - 'default' => 'post-block-style-default', - 'options' => [ - 'post-block-style-default' => esc_html__( 'Default', 'essential-addons-elementor' ), - 'post-block-style-overlay' => esc_html__( 'Overlay', 'essential-addons-elementor' ), - ], - ] - ); - } - - if( 'eael-post-carousel' !== $this->get_name() ) { - - /** - * Show Read More - * @uses ContentTimeLine Elements - EAE - */ - if( 'eael-content-timeline' === $this->get_name() ) { - - $this->add_control( - 'eael_show_read_more', - [ - 'label' => __( 'Show Read More', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( 'Yes', 'essential-addons-elementor' ), - 'icon' => 'fa fa-check', - ], - '0' => [ - 'title' => __( 'No', 'essential-addons-elementor' ), - 'icon' => 'fa fa-ban', - ] - ], - 'default' => '1', - 'condition' => [ - 'eael_content_timeline_choose' => 'dynamic' - ] - ] - ); - - $this->add_control( - 'eael_read_more_text', - [ - 'label' => esc_html__( 'Label Text', 'essential-addons-elementor' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => false, - 'default' => esc_html__( 'Read More', 'essential-addons-elementor' ), - 'condition' => [ - 'eael_content_timeline_choose' => 'dynamic', - 'eael_show_read_more' => '1', - ] - ] - ); - - } else { - - $this->add_control( - 'show_load_more', - [ - 'label' => __( 'Show Load More', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( 'Yes', 'essential-addons-elementor' ), - 'icon' => 'fa fa-check', - ], - '0' => [ - 'title' => __( 'No', 'essential-addons-elementor' ), - 'icon' => 'fa fa-ban', - ] - ], - 'default' => '0' - ] - ); - - $this->add_control( - 'show_load_more_text', - [ - 'label' => esc_html__( 'Label Text', 'essential-addons-elementor' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => false, - 'default' => esc_html__( 'Load More', 'essential-addons-elementor' ), - 'condition' => [ - 'show_load_more' => '1', - ] - ] - ); - } - - } - - if( 'eael-content-timeline' !== $this->get_name() ) { - $this->add_control( - 'eael_show_image', - [ - 'label' => __( 'Show Image', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( 'Yes', 'essential-addons-elementor' ), - 'icon' => 'fa fa-check', - ], - '0' => [ - 'title' => __( 'No', 'essential-addons-elementor' ), - 'icon' => 'fa fa-ban', - ] - ], - 'default' => '1' - ] - ); - $this->add_group_control( - Group_Control_Image_Size::get_type(), - [ - 'name' => 'image', - 'exclude' => [ 'custom' ], - 'default' => 'medium', - 'condition' => [ - 'eael_show_image' => '1', - ] - ] - ); - - } - - if( 'eael-content-timeline' === $this->get_name() ) { - - $this->add_control( - 'eael_show_image_or_icon', - [ - 'label' => __( 'Show Circle Image / Icon', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - 'img' => [ - 'title' => __( 'Image', 'essential-addons-elementor' ), - 'icon' => 'fa fa-picture-o', - ], - 'icon' => [ - 'title' => __( 'Icon', 'essential-addons-elementor' ), - 'icon' => 'fa fa-info', - ], - 'bullet' => [ - 'title' => __( 'Bullet', 'essential-addons-elementor' ), - 'icon' => 'fa fa-circle', - ] - ], - 'default' => 'icon', - 'condition' => [ - 'eael_content_timeline_choose' => 'dynamic' - ] - ] - ); - - $this->add_control( - 'eael_icon_image', - [ - 'label' => esc_html__( 'Icon Image', 'essential-addons-elementor' ), - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - 'condition' => [ - 'eael_show_image_or_icon' => 'img', - ] - ] - ); - $this->add_control( - 'eael_icon_image_size', - [ - 'label' => esc_html__( 'Icon Image Size', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SLIDER, - 'default' => [ - 'size' => 24, - ], - 'range' => [ - 'px' => [ - 'max' => 60, - ], - ], - 'condition' => [ - 'eael_show_image_or_icon' => 'img', - ], - 'selectors' => [ - '{{WRAPPER}} .eael-content-timeline-img img' => 'width: {{SIZE}}px;', - ], - ] - ); - - $this->add_control( - 'eael_content_timeline_circle_icon', - [ - 'label' => esc_html__( 'Icon', 'essential-addons-elementor' ), - 'type' => Controls_Manager::ICON, - 'default' => 'fa fa-pencil', - 'condition' => [ - 'eael_content_timeline_choose' => 'dynamic', - 'eael_show_image_or_icon' => 'icon', - ] - ] - ); - - } - - $this->add_control( - 'eael_show_title', - [ - 'label' => __( 'Show Title', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( 'Yes', 'essential-addons-elementor' ), - 'icon' => 'fa fa-check', - ], - '0' => [ - 'title' => __( 'No', 'essential-addons-elementor' ), - 'icon' => 'fa fa-ban', - ] - ], - 'default' => '1' - ] - ); - - $this->add_control( - 'eael_show_excerpt', - [ - 'label' => __( 'Show excerpt', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( 'Yes', 'essential-addons-elementor' ), - 'icon' => 'fa fa-check', - ], - '0' => [ - 'title' => __( 'No', 'essential-addons-elementor' ), - 'icon' => 'fa fa-ban', - ] - ], - 'default' => '1' - ] - ); - - $this->add_control( - 'eael_excerpt_length', - [ - 'label' => __( 'Excerpt Words', 'essential-addons-elementor' ), - 'type' => Controls_Manager::NUMBER, - 'default' => '10', - 'condition' => [ - 'eael_show_excerpt' => '1', - ], - 'description' => ' Pro Feature. Get Pro version ' - ] - ); - - if( 'eael-post-grid' === $this->get_name() || 'eael-post-block' === $this->get_name() || 'eael-post-carousel' === $this->get_name() ) { - - $this->add_control( - 'eael_show_meta', - [ - 'label' => __( 'Show Meta', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - '1' => [ - 'title' => __( 'Yes', 'essential-addons-elementor' ), - 'icon' => 'fa fa-check', - ], - '0' => [ - 'title' => __( 'No', 'essential-addons-elementor' ), - 'icon' => 'fa fa-ban', - ] - ], - 'default' => '1' - ] - ); - - $this->add_control( - 'meta_position', - [ - 'label' => esc_html__( 'Meta Position', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SELECT, - 'default' => 'meta-entry-footer', - 'options' => [ - 'meta-entry-header' => esc_html__( 'Entry Header', 'essential-addons-elementor' ), - 'meta-entry-footer' => esc_html__( 'Entry Footer', 'essential-addons-elementor' ), - ], - 'condition' => [ - 'eael_show_meta' => '1', - ] - ] - ); - - } - - $this->end_controls_section(); - - } - - /** - * Load More Button Style - * with Hover! - */ - protected function load_more_button_style(){ - - $this->start_controls_section( - 'eael_section_load_more_btn', - [ - 'label' => __( 'Load More Button Style', 'essential-addons-elementor' ), - 'tab' => Controls_Manager::TAB_STYLE, - 'condition' => [ - 'show_load_more' => '1' - ] - ] - ); - - $this->add_responsive_control( - 'eael_post_grid_load_more_btn_padding', - [ - 'label' => esc_html__( 'Padding', 'essential-addons-elementor' ), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => [ 'px', 'em', '%' ], - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ], - ] - ); - - $this->add_responsive_control( - 'eael_post_grid_load_more_btn_margin', - [ - 'label' => esc_html__( 'Margin', 'essential-addons-elementor' ), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => [ 'px', 'em', '%' ], - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ], - ] - ); - $this->add_group_control( - Group_Control_Typography::get_type(), - [ - 'name' => 'eael_post_grid_load_more_btn_typography', - 'selector' => '{{WRAPPER}} .eael-load-more-button', - ] - ); - - $this->start_controls_tabs( 'eael_post_grid_load_more_btn_tabs' ); - - // Normal State Tab - $this->start_controls_tab( 'eael_post_grid_load_more_btn_normal', [ 'label' => esc_html__( 'Normal', 'essential-addons-elementor' ) ] ); - - $this->add_control( - 'eael_post_grid_load_more_btn_normal_text_color', - [ - 'label' => esc_html__( 'Text Color', 'essential-addons-elementor' ), - 'type' => Controls_Manager::COLOR, - 'default' => '#fff', - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button' => 'color: {{VALUE}};', - ], - ] - ); - - $this->add_control( - 'eael_cta_btn_normal_bg_color', - [ - 'label' => esc_html__( 'Background Color', 'essential-addons-elementor' ), - 'type' => Controls_Manager::COLOR, - 'default' => '#29d8d8', - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button' => 'background: {{VALUE}};', - ], - ] - ); - - $this->add_group_control( - Group_Control_Border::get_type(), - [ - 'name' => 'eael_post_grid_load_more_btn_normal_border', - 'label' => esc_html__( 'Border', 'essential-addons-elementor' ), - 'selector' => '{{WRAPPER}} .eael-load-more-button', - ] - ); - - $this->add_control( - 'eael_post_grid_load_more_btn_border_radius', - [ - 'label' => esc_html__( 'Border Radius', 'essential-addons-elementor' ), - 'type' => Controls_Manager::SLIDER, - 'range' => [ - 'px' => [ - 'max' => 100, - ], - ], - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button' => 'border-radius: {{SIZE}}px;', - ], - ] - ); - $this->add_group_control( - Group_Control_Box_Shadow::get_type(), - [ - 'name' => 'eael_post_grid_load_more_btn_shadow', - 'selector' => '{{WRAPPER}} .eael-load-more-button', - 'separator' => 'before' - ] - ); - - $this->end_controls_tab(); - - // Hover State Tab - $this->start_controls_tab( 'eael_post_grid_load_more_btn_hover', [ 'label' => esc_html__( 'Hover', 'essential-addons-elementor' ) ] ); - - $this->add_control( - 'eael_post_grid_load_more_btn_hover_text_color', - [ - 'label' => esc_html__( 'Text Color', 'essential-addons-elementor' ), - 'type' => Controls_Manager::COLOR, - 'default' => '#fff', - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button:hover' => 'color: {{VALUE}};', - ], - ] - ); - - $this->add_control( - 'eael_post_grid_load_more_btn_hover_bg_color', - [ - 'label' => esc_html__( 'Background Color', 'essential-addons-elementor' ), - 'type' => Controls_Manager::COLOR, - 'default' => '#27bdbd', - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button:hover' => 'background: {{VALUE}};', - ], - ] - ); - - $this->add_control( - 'eael_post_grid_load_more_btn_hover_border_color', - [ - 'label' => esc_html__( 'Border Color', 'essential-addons-elementor' ), - 'type' => Controls_Manager::COLOR, - 'default' => '', - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button:hover' => 'border-color: {{VALUE}};', - ], - ] - - ); - $this->add_group_control( - Group_Control_Box_Shadow::get_type(), - [ - 'name' => 'eael_post_grid_load_more_btn_hover_shadow', - 'selector' => '{{WRAPPER}} .eael-load-more-button:hover', - 'separator' => 'before' - ] - ); - $this->end_controls_tab(); - - $this->end_controls_tabs(); - - $this->add_responsive_control( - 'eael_post_grid_loadmore_button_alignment', - [ - 'label' => __( 'Button Alignment', 'essential-addons-elementor' ), - 'type' => Controls_Manager::CHOOSE, - 'options' => [ - 'flex-start' => [ - 'title' => __( 'Left', 'essential-addons-elementor' ), - 'icon' => 'fa fa-align-left', - ], - 'center' => [ - 'title' => __( 'Center', 'essential-addons-elementor' ), - 'icon' => 'fa fa-align-center', - ], - 'flex-end' => [ - 'title' => __( 'Right', 'essential-addons-elementor' ), - 'icon' => 'fa fa-align-right', - ] - ], - 'default' => 'center', - 'selectors' => [ - '{{WRAPPER}} .eael-load-more-button-wrap' => 'justify-content: {{VALUE}};', - ] - ] - ); - - $this->end_controls_section(); - - } - -} - -class EAE_Helper { - - public static function get_query_args( $control_id, $settings ) { - $defaults = [ - $control_id . '_post_type' => 'post', - $control_id . '_posts_ids' => [], - 'orderby' => 'date', - 'order' => 'desc', - 'posts_per_page' => 3, - 'offset' => 0, - ]; - - $settings = wp_parse_args( $settings, $defaults ); - - $post_type = $settings[ $control_id . '_post_type' ]; - - $query_args = [ - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'ignore_sticky_posts' => 1, - 'post_status' => 'publish', // Hide drafts/private posts for admins - ]; - - if ( 'by_id' === $post_type ) { - $query_args['post_type'] = 'any'; - $query_args['post__in'] = $settings[ $control_id . '_posts_ids' ]; - - if ( empty( $query_args['post__in'] ) ) { - // If no selection - return an empty query - $query_args['post__in'] = [ 0 ]; - } - } else { - $query_args['post_type'] = $post_type; - $query_args['posts_per_page'] = $settings['posts_per_page']; - $query_args['tax_query'] = []; - - $query_args['offset'] = $settings['offset']; - - $taxonomies = get_object_taxonomies( $post_type, 'objects' ); - - foreach ( $taxonomies as $object ) { - $setting_key = $control_id . '_' . $object->name . '_ids'; - - if ( ! empty( $settings[ $setting_key ] ) ) { - $query_args['tax_query'][] = [ - 'taxonomy' => $object->name, - 'field' => 'term_id', - 'terms' => $settings[ $setting_key ], - ]; - } - } - } - - if ( ! empty( $settings[ $control_id . '_authors' ] ) ) { - $query_args['author__in'] = $settings[ $control_id . '_authors' ]; - } - - $post__not_in = []; - if ( ! empty( $settings['post__not_in'] ) ) { - $post__not_in = array_merge( $post__not_in, $settings['post__not_in'] ); - $query_args['post__not_in'] = $post__not_in; - } - - if( isset( $query_args['tax_query'] ) && count( $query_args['tax_query'] ) > 1 ) { - $query_args['tax_query']['relation'] = 'OR'; - } - - return $query_args; - } - -} diff --git a/includes/extensions.php b/includes/extensions.php deleted file mode 100755 index ffe3018c7..000000000 --- a/includes/extensions.php +++ /dev/null @@ -1,46 +0,0 @@ -reflection = new \ReflectionClass( $this ); - } - -} \ No newline at end of file diff --git a/includes/queries.php b/includes/queries.php deleted file mode 100755 index 791bcdc52..000000000 --- a/includes/queries.php +++ /dev/null @@ -1,549 +0,0 @@ - true, 'show_in_nav_menus' => true ), 'object' ); - $eael_exclude_cpts = array( 'elementor_library', 'attachment' ); - - foreach ( $eael_exclude_cpts as $exclude_cpt ) { - unset($eael_cpts[$exclude_cpt]); - } - $post_types = array_merge($eael_cpts); - foreach( $post_types as $type ) { - $types[ $type->name ] = $type->label; - } - - return $types; -} - -/** - * Get all types of post. - * @return array - */ -function eael_get_all_types_post(){ - $posts_args = array( - 'post_type' => 'any', - 'post_style' => 'all_types', - 'post_status' => 'publish', - 'posts_per_page' => '-1', - ); - $posts = eael_load_more_ajax( $posts_args ); - - $post_list = []; - - foreach( $posts as $post ) { - $post_list[ $post->ID ] = $post->post_title; - } - - return $post_list; -} -/** - * Post Settings Parameter - * @param array $settings - * @return array - */ -function eael_get_post_settings( $settings ){ - foreach( $settings as $key => $value ) { - if( in_array( $key, posts_args() ) ) { - $post_args[ $key ] = $value; - } - } - - $post_args['post_style'] = isset( $post_args['post_style'] ) ? $post_args['post_style'] : 'grid'; - $post_args['post_status'] = 'publish'; - - return $post_args; -} - -/** - * Getting Excerpts By Post Id - * @param int $post_id - * @param int $excerpt_length - * @return string - */ -function eael_get_excerpt_by_id( $post_id, $excerpt_length ){ - $the_post = get_post( $post_id ); //Gets post ID - - $the_excerpt = null; - if( $the_post ){ - $the_excerpt = $the_post->post_excerpt ? $the_post->post_excerpt : $the_post->post_content; - } - - $the_excerpt = strip_tags( strip_shortcodes( $the_excerpt ) ); //Strips tags and images - $words = explode(' ', $the_excerpt, $excerpt_length + 1); - - if(count($words) > $excerpt_length) : - array_pop($words); - array_push($words, '…'); - $the_excerpt = implode(' ', $words); - endif; - - return $the_excerpt; -} - -/** - * Get Post Thumbnail Size - * @return array - */ -function eael_get_thumbnail_sizes(){ - $sizes = get_intermediate_image_sizes(); - foreach($sizes as $s){ - $ret[$s] = $s; - } - - return $ret; -} - -/** - * POst Orderby Options - * @return array - */ -function eael_get_post_orderby_options(){ - $orderby = array( - 'ID' => 'Post ID', - 'author' => 'Post Author', - 'title' => 'Title', - 'date' => 'Date', - 'modified' => 'Last Modified Date', - 'parent' => 'Parent Id', - 'rand' => 'Random', - 'comment_count' => 'Comment Count', - 'menu_order' => 'Menu Order', - ); - - return $orderby; -} - -/** - * Get Post Categories - * @return array - */ -function eael_post_type_categories(){ - $terms = get_terms( array( - 'taxonomy' => 'category', - 'hide_empty' => true, - )); - - if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ - foreach ( $terms as $term ) { - $options[ $term->term_id ] = $term->name; - } - } - - return $options; -} - -/** - * WooCommerce Product Query - * @return array - */ -function eael_woocommerce_product_categories(){ - $terms = get_terms( array( - 'taxonomy' => 'product_cat', - 'hide_empty' => true, - )); - - if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ - foreach ( $terms as $term ) { - $options[ $term->slug ] = $term->name; - } - return $options; - } -} - -/** - * WooCommerce Get Product By Id - * @return array - */ -function eael_woocommerce_product_get_product_by_id(){ - $postlist = get_posts(array( - 'post_type' => 'product', - 'showposts' => 9999, - )); - $options = array(); - - if ( ! empty( $postlist ) && ! is_wp_error( $postlist ) ){ - foreach ( $postlist as $post ) { - $options[ $post->ID ] = $post->post_title; - } - return $options; - - } -} - -/** - * WooCommerce Get Product Category By Id - * @return array - */ -function eael_woocommerce_product_categories_by_id(){ - $terms = get_terms( array( - 'taxonomy' => 'product_cat', - 'hide_empty' => true, - )); - - if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ - foreach ( $terms as $term ) { - $options[ $term->term_id ] = $term->name; - } - return $options; - } - -} - -/** - * Get Contact Form 7 [ if exists ] - */ -if ( function_exists( 'wpcf7' ) ) { - function eael_select_contact_form(){ - $wpcf7_form_list = get_posts(array( - 'post_type' => 'wpcf7_contact_form', - 'showposts' => 999, - )); - $options = array(); - $options[0] = esc_html__( 'Select a Contact Form', 'essential-addons-elementor' ); - if ( ! empty( $wpcf7_form_list ) && ! is_wp_error( $wpcf7_form_list ) ){ - foreach ( $wpcf7_form_list as $post ) { - $options[ $post->ID ] = $post->post_title; - } - } else { - $options[0] = esc_html__( 'Create a Form First', 'essential-addons-elementor' ); - } - return $options; - } -} - -/** - * Get Gravity Form [ if exists ] - */ -if ( !function_exists('eael_select_gravity_form') ) { - function eael_select_gravity_form() { - $options = array(); - if ( class_exists( 'GFCommon' ) ) { - $gravity_forms = RGFormsModel::get_forms( null, 'title' ); - - if ( ! empty( $gravity_forms ) && ! is_wp_error( $gravity_forms ) ) { - - $options[0] = esc_html__( 'Select Gravity Form', 'essential-addons-elementor' ); - foreach ( $gravity_forms as $form ) { - $options[ $form->id ] = $form->title; - } - - } else { - $options[0] = esc_html__( 'Create a Form First', 'essential-addons-elementor' ); - } - } - - return $options; - } -} - -/** - * Get WeForms Form List - * @return array - */ -function eael_select_weform() { - - $wpuf_form_list = get_posts( array( - 'post_type' => 'wpuf_contact_form', - 'showposts' => 999, - )); - - $options = array(); - - if ( ! empty( $wpuf_form_list ) && ! is_wp_error( $wpuf_form_list ) ) { - $options[0] = esc_html__( 'Select weForm', 'essential-addons-elementor' ); - foreach ( $wpuf_form_list as $post ) { - $options[ $post->ID ] = $post->post_title; - } - } else { - $options[0] = esc_html__( 'Create a Form First', 'essential-addons-elementor' ); - } - - return $options; -} - -/** - * Get Ninja Form List - * @return array - */ -if ( !function_exists('eael_select_ninja_form') ) { - function eael_select_ninja_form() { - $options = array(); - if ( class_exists( 'Ninja_Forms' ) ) { - $contact_forms = Ninja_Forms()->form()->get_forms(); - - if ( ! empty( $contact_forms ) && ! is_wp_error( $contact_forms ) ) { - - $options[0] = esc_html__( 'Select Ninja Form', 'essential-addons-elementor' ); - - foreach ( $contact_forms as $form ) { - $options[ $form->get_id() ] = $form->get_setting( 'title' ); - } - } - } else { - $options[0] = esc_html__( 'Create a Form First', 'essential-addons-elementor' ); - } - - return $options; - } -} - -/** - * Get Caldera Form List - * @return array - */ -if ( !function_exists('eael_select_caldera_form') ) { - function eael_select_caldera_form() { - $options = array(); - if ( class_exists( 'Caldera_Forms' ) ) { - - $contact_forms = Caldera_Forms_Forms::get_forms( true, true ); - - if ( ! empty( $contact_forms ) && ! is_wp_error( $contact_forms ) ) { - $options[0] = esc_html__( 'Select Caldera Form', 'essential-addons-elementor' ); - foreach ( $contact_forms as $form ) { - $options[ $form['ID'] ] = $form['name']; - } - } - } else { - $options[0] = esc_html__( 'Create a Form First', 'essential-addons-elementor' ); - } - - return $options; - } -} - -/** - * Get WPForms List - * @return array - */ -if ( !function_exists('eael_select_wpforms_forms') ) { - function eael_select_wpforms_forms() { - $options = array(); - if ( class_exists( '\WPForms\WPForms' ) ) { - - $args = array( - 'post_type' => 'wpforms', - 'posts_per_page' => -1 - ); - - $contact_forms = get_posts( $args ); - - if ( ! empty( $contact_forms ) && ! is_wp_error( $contact_forms ) ) { - $options[0] = esc_html__( 'Select a WPForm', 'essential-addons-elementor' ); - foreach ( $contact_forms as $post ) { - $options[ $post->ID ] = $post->post_title; - } - } - } else { - $options[0] = esc_html__( 'Create a Form First', 'essential-addons-elementor' ); - } - - return $options; - } -} - -// Get all elementor page templates -if ( !function_exists('eael_get_page_templates') ) { - function eael_get_page_templates(){ - $page_templates = get_posts( array( - 'post_type' => 'elementor_library', - 'posts_per_page' => -1 - )); - - $options = array(); - - if ( ! empty( $page_templates ) && ! is_wp_error( $page_templates ) ){ - foreach ( $page_templates as $post ) { - $options[ $post->ID ] = $post->post_title; - } - } - return $options; - } -} - -// Get all Authors -if ( !function_exists('eael_get_authors') ) { - function eael_get_authors() { - - $options = array(); - - $users = get_users(); - - if($users) { - foreach( $users as $user ) { - $options[ $user->ID ] = $user->display_name; - } - } - - return $options; - } -} - -// Get all Authors -if ( !function_exists('eael_get_tags') ) { - function eael_get_tags() { - - $options = array(); - - $tags = get_tags(); - - foreach ( $tags as $tag ) { - $options[ $tag->term_id ] = $tag->name; - } - - return $options; - } -} - -// Get all Posts -if ( !function_exists('eael_get_posts') ) { - function eael_get_posts() { - - $post_list = get_posts( array( - 'post_type' => 'post', - 'orderby' => 'date', - 'order' => 'DESC', - 'posts_per_page' => -1, - ) ); - - $posts = array(); - - if ( ! empty( $post_list ) && ! is_wp_error( $post_list ) ) { - foreach ( $post_list as $post ) { - $posts[ $post->ID ] = $post->post_title; - } - } - - return $posts; - } -} - -// Get all Pages -if ( !function_exists('eael_get_pages') ) { - function eael_get_pages() { - - $page_list = get_posts( array( - 'post_type' => 'page', - 'orderby' => 'date', - 'order' => 'DESC', - 'posts_per_page' => -1, - ) ); - - $pages = array(); - - if ( ! empty( $page_list ) && ! is_wp_error( $page_list ) ) { - foreach ( $page_list as $page ) { - $pages[ $page->ID ] = $page->post_title; - } - } - - return $pages; - } -} - - -/** - * This function is responsible for get the post data. - * It will return HTML markup with AJAX call and with normal call. - * - * @return string of an html markup with AJAX call. - * @return array of content and found posts count without AJAX call. - */ -if( ! function_exists( 'eael_load_more_ajax' ) ) : - function eael_load_more_ajax(){ - - if( isset( $_POST['action'] ) && $_POST['action'] == 'load_more' ) { - $post_args = eael_get_post_settings( $_POST ); - $post_args = array_merge( \Elementor\EAE_Helper::get_query_args( 'eaeposts', $_POST ), $post_args ); - - if( isset( $_POST['tax_query'] ) && count( $_POST['tax_query'] ) > 1 ) { - $post_args['tax_query']['relation'] = 'OR'; - } - } else { - $args = func_get_args(); - $post_args = $args[0]; - } - - - $posts = new WP_Query( $post_args ); - /** - * For returning all types of post as an array - * @return array; - */ - if( isset( $post_args['post_style'] ) && $post_args['post_style'] == 'all_types' ) { - return $posts->posts; - } - - $return = array(); - $return['count'] = $posts->found_posts; - - ob_start(); - - while( $posts->have_posts() ) : $posts->the_post(); - $isPrinted = false; - /** - * All content html here. - */ - include ESSENTIAL_ADDONS_EL_PATH . 'includes/templates/content.php'; - endwhile; - $return['content'] = ob_get_clean(); - wp_reset_postdata(); - wp_reset_query(); - if( isset( $_POST['action'] ) && $_POST['action'] == 'load_more' ) { - echo $return['content']; - die(); - } else { - return $return; - } - } - add_action( 'wp_ajax_nopriv_load_more', 'eael_load_more_ajax' ); - add_action( 'wp_ajax_load_more', 'eael_load_more_ajax' ); -endif; - -/** - * For All Settings Key Need To Display - * - * @return array - */ -function posts_args(){ - return array( - // for content-ticker - 'eael_ticker_type', - 'eael_ticker_custom_contents', - - 'eael_post_grid_columns', - - // common - 'meta_position', - 'eael_show_meta', - 'image_size', - 'eael_show_image', - 'eael_show_title', - 'eael_show_excerpt', - 'eael_excerpt_length', - 'eael_show_read_more', - 'eael_read_more_text', - 'show_load_more', - 'show_load_more_text', - 'eael_post_grid_bg_hover_icon', - - // query_args - 'post_type', - 'post__in', - 'posts_per_page', - 'post_style', - 'tax_query', - 'post__not_in', - 'eael_post_authors', - 'eaeposts_authors', - 'offset', - 'orderby', - 'order', - 'eael_post_grid_hover_animation' - ); -} \ No newline at end of file diff --git a/admin/partials/elements.php b/includes/templates/admin/elements.php similarity index 89% rename from admin/partials/elements.php rename to includes/templates/admin/elements.php index f50f51a8d..eafe53b6b 100755 --- a/admin/partials/elements.php +++ b/includes/templates/admin/elements.php @@ -4,151 +4,156 @@You can disable the elements you are not using on your site. That will disable all associated assets of those widgets to improve your site loading.