Esempio n. 1
0
 public function add_control($id, $args)
 {
     if (null !== $this->_current_tab) {
         $args = array_merge($args, $this->_current_tab);
     }
     return Plugin::instance()->controls_manager->add_control_to_stack($this, $id, $args);
 }
Esempio n. 2
0
 public static function init()
 {
     // Hotfix for NextGEN Gallery plugin
     if (defined('NGG_PLUGIN_VERSION')) {
         add_filter('elementor/utils/get_edit_link', function ($edit_link) {
             return add_query_arg('display_gallery_iframe', '', $edit_link);
         });
     }
     // Hack for Ninja Forms
     if (class_exists('\\Ninja_Forms')) {
         add_action('elementor/preview/enqueue_styles', function () {
             ob_start();
             \NF_Display_Render::localize(0);
             ob_clean();
             wp_add_inline_script('nf-front-end', 'var nfForms = nfForms || [];');
         });
     }
     // Exclude our Library from sitemap.xml in Yoast SEO plugin
     add_filter('wpseo_sitemaps_supported_post_types', function ($post_types) {
         unset($post_types[TemplateLibrary\Source_Local::CPT]);
         return $post_types;
     });
     // Disable optimize files in Editor from Autoptimize plugin
     add_filter('autoptimize_filter_noptimize', function ($retval) {
         if (Plugin::instance()->editor->is_edit_mode()) {
             $retval = true;
         }
         return $retval;
     });
 }
Esempio n. 3
0
 /**
  * Add language translations to update_plugins or update_themes transients.
  *
  * @param $transient
  *
  * @return mixed
  */
 public function pre_set_site_transient($transient)
 {
     $locales = get_available_languages();
     $locales = !empty($locales) ? $locales : array(get_locale());
     $repos = array();
     if (!isset($transient->translations)) {
         return $transient;
     }
     if ('pre_set_site_transient_update_plugins' === current_filter()) {
         $repos = Plugin::instance()->get_plugin_configs();
         $translations = wp_get_installed_translations('plugins');
     }
     if ('pre_set_site_transient_update_themes' === current_filter()) {
         $repos = Theme::instance()->get_theme_configs();
         $translations = wp_get_installed_translations('themes');
     }
     $repos = array_filter($repos, function ($e) {
         return isset($e->language_packs);
     });
     foreach ($repos as $repo) {
         foreach ($locales as $locale) {
             $lang_pack_mod = isset($repo->language_packs->{$locale}) ? strtotime($repo->language_packs->{$locale}->updated) : 0;
             $translation_mod = isset($translations[$repo->repo][$locale]) ? strtotime($translations[$repo->repo][$locale]['PO-Revision-Date']) : 0;
             if ($lang_pack_mod > $translation_mod) {
                 $transient->translations[] = (array) $repo->language_packs->{$locale};
             }
         }
     }
     $transient->translations = array_unique($transient->translations, SORT_REGULAR);
     return $transient;
 }
Esempio n. 4
0
 /**
  * Initializing plugins
  *
  * @return Plugin
  */
 public static function init()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Plugin();
     }
     return self::$instance;
 }
Esempio n. 5
0
 /**
  * CONSTRUCTOR - Initialize
  */
 public function __construct($start = '')
 {
     // Managed directives
     ini_set('default_charset', $charset = 'UTF-8');
     ini_set('display_errors', 1);
     // Abort on startup error
     // Intercept errors/exceptions; PHP5.3-compatible
     error_reporting(E_ALL | E_STRICT);
     if (!ini_get('date.timezone')) {
         date_default_timezone_set('GMT');
     }
     // define shorthand paths
     if (!defined('BASE')) {
         $base = dirname(__FILE__) . '/';
         define("BASE", $base);
         define("CACHE", $base . 'cache/');
         define("ADMIN", $base . 'admin/');
         define("INSTALL", $base . 'install/');
         define("LIBS", $base . 'libs/');
         define("EXTENSIONS", $base . 'libs/extensions/');
         define("FRAMEWORKS", $base . 'libs/frameworks/');
         define("FUNCTIONS", $base . 'functions/');
         define("CONTENT", $base . 'content/');
         define("THEMES", $base . 'content/themes/');
         define("PLUGINS", $base . 'content/plugins/');
         define("ADMIN_THEMES", $base . 'content/admin_themes/');
         define("SITEURL", BASEURL);
     }
     if (!$start) {
         // initialize
         parent::__construct();
         $this->currentUser = UserBase::instance();
         // the current user
         $this->displayUser = DisplayUser::instance();
         $this->plugin = Plugin::instance();
         // instantiate Plugin object
         $this->post = Post::instance();
         // instantiate Post object
         $this->comment = Comment::instance();
         $this->includes = IncludeCssJs::instance();
         // instantiate Includes object
         $this->pageHandling = PageHandling::instance();
         // instantiate PageHandling object
         $this->debug = Debug::instance();
         // instantiate Debug object
         $this->csrf('set');
         // set a csrfToken
         $this->db->setHotaru($this);
         // pass $h object to EzSQL for error reporting
         //$this->mdb->setHotaru($this);               // pass $h object to meekroDb for error reporting
         //print 'time: ' . timer_stop(4,'hotaru');
         //roughly here at 0.0040 Nov 2, 2014 tests
         // time: 0.0047 Nov11, 2014 after moving a few more functions to init
     }
 }
Esempio n. 6
0
 /**
  * Fetch images and replace to new
  *
  * @param $settings
  *
  * @return array|bool
  */
 public function on_import($settings)
 {
     if (empty($settings['url'])) {
         return $settings;
     }
     $settings = Plugin::instance()->templates_manager->get_import_images_instance()->import($settings);
     if (!$settings) {
         $settings = ['id' => '', 'url' => Utils::get_placeholder_image_src()];
     }
     return $settings;
 }
Esempio n. 7
0
 public function on_import($settings)
 {
     foreach ($settings as &$attachment) {
         if (empty($attachment['url'])) {
             continue;
         }
         $attachment = Plugin::instance()->templates_manager->get_import_images_instance()->import($attachment);
     }
     // Filter out attachments that doesn't exist
     $settings = array_filter($settings);
     return $settings;
 }
Esempio n. 8
0
 /**
  * Handle the post lock in the editor.
  *
  * @since 1.0.0
  *
  * @param array $response
  * @param array $data
  *
  * @return array
  */
 public function heartbeat_received($response, $data)
 {
     if (isset($data['elementor_post_lock']['post_ID'])) {
         $post_id = $data['elementor_post_lock']['post_ID'];
         $locked_user = Plugin::instance()->editor->get_locked_user($post_id);
         if (!$locked_user || !empty($data['elementor_force_post_lock'])) {
             Plugin::instance()->editor->lock_post($post_id);
         } else {
             $response['locked_user'] = $locked_user->display_name;
         }
         $response['elementor_nonce'] = wp_create_nonce('elementor-editing');
     }
     return $response;
 }
Esempio n. 9
0
 public function get_value($control, $instance)
 {
     $value = parent::get_value($control, $instance);
     if (!empty($value)) {
         foreach ($value as &$item) {
             foreach ($control['fields'] as $field) {
                 $control_obj = Plugin::instance()->controls_manager->get_control($field['type']);
                 if (!$control_obj) {
                     continue;
                 }
                 $item[$field['name']] = $control_obj->get_value($field, $item);
             }
         }
     }
     return $value;
 }
Esempio n. 10
0
 /**
  * Shiny updates results in the update transient being reset with only the wp.org data.
  * This catches the response and reloads the transients.
  *
  * @param mixed  $response HTTP server response.
  * @param array  $args     HTTP response arguments.
  * @param string $url      URL of HTTP response.
  *
  * @return mixed $response Just a pass through, no manipulation.
  */
 public static function wp_update_response($response, $args, $url)
 {
     $parsed_url = parse_url($url);
     if ('api.wordpress.org' === $parsed_url['host']) {
         if (current_user_can('update_plugins') && isset($args['body']['plugins'])) {
             $current = get_site_transient('update_plugins');
             Plugin::instance()->forced_meta_update_plugins(true);
             $current = Plugin::instance()->pre_set_site_transient_update_plugins($current);
             set_site_transient('update_plugins', $current);
         }
         if (current_user_can('update_themes') && isset($args['body']['themes'])) {
             $current = get_site_transient('update_themes');
             Theme::instance()->forced_meta_update_themes(true);
             $current = Theme::instance()->pre_set_site_transient_update_themes($current);
             set_site_transient('update_themes', $current);
         }
     }
     return $response;
 }
Esempio n. 11
0
 /**
  * This function notifies the user of upgrade notices, new templates and contributors
  *
  * @param bool $force
  *
  * @return array|bool
  */
 private static function _get_info_data($force = false)
 {
     $cache_key = 'elementor_remote_info_api_data_' . Plugin::instance()->get_version();
     $info_data = get_transient($cache_key);
     if ($force || false === $info_data) {
         $response = wp_remote_post(self::$api_info_url, ['timeout' => 25, 'body' => ['api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo('language')]]);
         if (is_wp_error($response) || 200 !== (int) wp_remote_retrieve_response_code($response)) {
             set_transient($cache_key, [], 2 * HOUR_IN_SECONDS);
             return false;
         }
         $info_data = json_decode(wp_remote_retrieve_body($response), true);
         if (empty($info_data) || !is_array($info_data)) {
             set_transient($cache_key, [], 2 * HOUR_IN_SECONDS);
             return false;
         }
         if (isset($info_data['templates'])) {
             update_option('elementor_remote_info_templates_data', $info_data['templates'], 'no');
             unset($info_data['templates']);
         }
         set_transient($cache_key, $info_data, 12 * HOUR_IN_SECONDS);
     }
     return $info_data;
 }
Esempio n. 12
0
 public function get_element_stack(Element_Base $element)
 {
     $stack_id = $element->get_name();
     if (!isset($this->_controls_stack[$stack_id])) {
         return null;
     }
     $stack = $this->_controls_stack[$stack_id];
     if ('widget' === $element->get_type() && 'common' !== $element->get_name()) {
         $common_widget = Plugin::instance()->widgets_manager->get_widget_types('common');
         $stack['controls'] = array_merge($stack['controls'], $common_widget->get_controls());
         $stack['tabs'] = array_merge($stack['tabs'], $common_widget->get_tabs_controls());
     }
     return $stack;
 }
Esempio n. 13
0
 /**
  * Create and return settings fields for private repositories.
  *
  * @return void
  */
 public function ghu_tokens()
 {
     $ghu_options_keys = array();
     $ghu_plugins = Plugin::instance()->get_plugin_configs();
     $ghu_themes = Theme::instance()->get_theme_configs();
     $ghu_tokens = array_merge($ghu_plugins, $ghu_themes);
     foreach ($ghu_tokens as $token) {
         $type = '<span class="dashicons dashicons-admin-plugins"></span>&nbsp;';
         $setting_field = array();
         $ghu_options_keys[$token->repo] = null;
         $token->private = isset($token->private) ? $token->private : true;
         /*
          * Set boolean for Enterprise headers.
          */
         if ($token->enterprise) {
             /*
              * Set boolean if GitHub Enterprise header found.
              */
             if (false !== strpos($token->type, 'github') && !parent::$auth_required['github_enterprise']) {
                 parent::$auth_required['github_enterprise'] = true;
             }
             /*
              * Set boolean if GitLab CE/Enterprise header found.
              */
             if (false !== strpos($token->type, 'gitlab') && !empty($token->enterprise) && !parent::$auth_required['gitlab_enterprise']) {
                 parent::$auth_required['gitlab_enterprise'] = true;
             }
         }
         /*
          * Check to see if it's a private repo and set variables.
          */
         if ($token->private) {
             if (false !== strpos($token->type, 'github') && !parent::$auth_required['github_private']) {
                 parent::$auth_required['github_private'] = true;
             }
             if (false !== strpos($token->type, 'bitbucket') && !parent::$auth_required['bitbucket_private']) {
                 parent::$auth_required['bitbucket_private'] = true;
             }
         }
         /*
          * Set boolean if GitLab header found.
          */
         if (false !== strpos($token->type, 'gitlab') && empty($token->enterprise) && !parent::$auth_required['gitlab']) {
             parent::$auth_required['gitlab'] = true;
         }
         /*
          * Next if not a private repo or token field not empty.
          */
         if (!$token->private && empty(parent::$options[$token->repo])) {
             continue;
         }
         if (false !== strpos($token->type, 'theme')) {
             $type = '<span class="dashicons dashicons-admin-appearance"></span>&nbsp;';
         }
         $setting_field['id'] = $token->repo;
         $setting_field['title'] = $type . $token->name;
         $setting_field['page'] = 'github_updater_install_settings';
         switch ($token->type) {
             case strpos($token->type, 'github'):
                 $setting_field['section'] = 'github_id';
                 $setting_field['callback_method'] = array(&$this, 'token_callback_text');
                 $setting_field['callback'] = $token->repo;
                 break;
             case strpos($token->type, 'bitbucket'):
                 $setting_field['section'] = 'bitbucket_id';
                 $setting_field['callback_method'] = array(&$this, 'token_callback_checkbox');
                 $setting_field['callback'] = $token->repo;
                 break;
             case strpos($token->type, 'gitlab'):
                 $setting_field['section'] = 'gitlab_id';
                 $setting_field['callback_method'] = array(&$this, 'token_callback_checkbox');
                 $setting_field['callback'] = $token->repo;
                 break;
         }
         add_settings_field($setting_field['id'], $setting_field['title'], $setting_field['callback_method'], $setting_field['page'], $setting_field['section'], array('id' => $setting_field['callback']));
     }
     /*
      * Unset options that are no longer present and update options.
      */
     $ghu_unset_keys = array_diff_key(parent::$options, $ghu_options_keys);
     unset($ghu_unset_keys['github_access_token']);
     if (parent::$auth_required['github_enterprise']) {
         unset($ghu_unset_keys['github_enterprise_token']);
     }
     unset($ghu_unset_keys['branch_switch']);
     unset($ghu_unset_keys['bitbucket_username']);
     unset($ghu_unset_keys['bitbucket_password']);
     if (parent::$auth_required['gitlab']) {
         unset($ghu_unset_keys['gitlab_private_token']);
     }
     if (parent::$auth_required['gitlab_enterprise']) {
         unset($ghu_unset_keys['gitlab_enterprise_token']);
     }
     if (!empty($ghu_unset_keys)) {
         foreach ($ghu_unset_keys as $key => $value) {
             unset(parent::$options[$key]);
         }
         update_site_option('github_updater', parent::$options);
     }
 }
Esempio n. 14
0
 protected function _get_child_type(array $element_data)
 {
     if ('section' === $element_data['elType']) {
         return Plugin::instance()->elements_manager->get_element_types('section');
     }
     return Plugin::instance()->widgets_manager->get_widget_types($element_data['widgetType']);
 }
Esempio n. 15
0
 /**
  * Return listing of available updates.
  *
  * @param $response
  *
  * @return mixed
  */
 public function show_updates($response)
 {
     $themes = get_site_transient('update_themes');
     $plugins = get_site_transient('update_plugins');
     $show_plugins = null;
     $show_themes = null;
     /*
      * Ensure update data is up to date.
      */
     $this->forced_meta_update_remote_management();
     $themes = Theme::instance()->pre_set_site_transient_update_themes($themes);
     $plugins = Plugin::instance()->pre_set_site_transient_update_plugins($plugins);
     foreach ($plugins->response as $plugin) {
         $plugin->plugin = $plugin->slug;
         unset($plugin->slug);
         unset($plugin->url);
         unset($plugin->package);
         if (isset($plugin->id, $plugin->tested, $plugin->compatibility)) {
             unset($plugin->id);
             unset($plugin->tested);
             unset($plugin->compatibility);
         }
         $show_plugins[] = $plugin;
     }
     foreach ($themes->response as $theme) {
         unset($theme['url']);
         unset($theme['package']);
         $show_themes[] = $theme;
     }
     $response['messages'] = esc_html__('Available Updates', 'github-updater');
     $response['plugins'] = $show_plugins;
     $response['themes'] = $show_themes;
     return $response;
 }
Esempio n. 16
0
 /**
  * Create and return settings fields for private repositories.
  *
  * @return void
  */
 public function ghu_tokens()
 {
     $ghu_options_keys = array();
     $plugin = get_site_transient('ghu_plugin');
     $theme = get_site_transient('ghu_theme');
     if (!$plugin) {
         $plugin = Plugin::instance();
         $plugin->get_remote_plugin_meta();
     }
     if (!$theme) {
         $theme = Theme::instance();
         $theme->get_remote_theme_meta();
     }
     $ghu_plugins = $plugin->config;
     $ghu_themes = $theme->config;
     $ghu_tokens = array_merge($ghu_plugins, $ghu_themes);
     foreach ($ghu_tokens as $token) {
         $type = '';
         $setting_field = array();
         $ghu_options_keys[$token->repo] = null;
         /*
          * Set boolean for Enterprise headers.
          */
         if ($token->enterprise) {
             /*
              * Set boolean if GitHub Enterprise header found.
              */
             if (false !== strpos($token->type, 'github') && !self::$github_enterprise) {
                 self::$github_enterprise = true;
             }
             /*
              * Set boolean if GitLab CE/Enterprise header found.
              */
             if (false !== strpos($token->type, 'gitlab') && !self::$gitlab_enterprise) {
                 self::$gitlab_enterprise = true;
             }
         }
         /*
          * Check to see if it's a private repo and set variables.
          */
         if ($token->private) {
             if (false !== strpos($token->type, 'github') && !self::$github_private) {
                 self::$github_private = true;
             }
             if (false !== strpos($token->type, 'bitbucket') && !self::$bitbucket_private) {
                 self::$bitbucket_private = true;
             }
         }
         /*
          * Set boolean if GitLab header found.
          */
         if (false !== strpos($token->type, 'gitlab') && !self::$gitlab) {
             self::$gitlab = true;
         }
         /*
          * Next if not a private repo or token field not empty.
          */
         if (!$token->private && empty(parent::$options[$token->repo])) {
             continue;
         }
         if (false !== strpos($token->type, 'theme')) {
             $type = esc_html__('Theme:', 'github-updater') . '&nbsp;';
         }
         $setting_field['id'] = $token->repo;
         $setting_field['title'] = $type . $token->name;
         $setting_field['page'] = 'github_updater_install_settings';
         switch ($token->type) {
             case strpos($token->type, 'github'):
                 $setting_field['section'] = 'github_id';
                 $setting_field['callback_method'] = array(&$this, 'token_callback_text');
                 $setting_field['callback'] = $token->repo;
                 break;
             case strpos($token->type, 'bitbucket'):
                 $setting_field['section'] = 'bitbucket_id';
                 $setting_field['callback_method'] = array(&$this, 'token_callback_checkbox');
                 $setting_field['callback'] = $token->repo;
                 break;
             case strpos($token->type, 'gitlab'):
                 $setting_field['section'] = 'gitlab_id';
                 $setting_field['callback_method'] = array(&$this, 'token_callback_checkbox');
                 $setting_field['callback'] = $token->repo;
                 break;
         }
         add_settings_field($setting_field['id'], $setting_field['title'], $setting_field['callback_method'], $setting_field['page'], $setting_field['section'], array('id' => $setting_field['callback']));
     }
     /*
      * Unset options that are no longer present and update options.
      */
     $ghu_unset_keys = array_diff_key(parent::$options, $ghu_options_keys);
     unset($ghu_unset_keys['github_access_token']);
     if (self::$github_enterprise) {
         unset($ghu_unset_keys['github_enterprise_token']);
     }
     unset($ghu_unset_keys['branch_switch']);
     unset($ghu_unset_keys['bitbucket_username']);
     unset($ghu_unset_keys['bitbucket_password']);
     if (self::$gitlab) {
         unset($ghu_unset_keys['gitlab_private_token']);
     }
     if (self::$gitlab_enterprise) {
         unset($ghu_unset_keys['gitlab_enterprise_token']);
     }
     if (!empty($ghu_unset_keys)) {
         foreach ($ghu_unset_keys as $key => $value) {
             unset(parent::$options[$key]);
         }
         update_site_option('github_updater', parent::$options);
     }
 }
Esempio n. 17
0
 /**
  * Write out listing of installed plugins and themes using GitHub Updater.
  * Places a lock dashicon before the repo name if it's a private repo.
  *
  * @param $type
  */
 private function display_ghu_repos($type)
 {
     $plugins = Plugin::instance()->get_plugin_configs();
     $themes = Theme::instance()->get_theme_configs();
     $repos = array_merge($plugins, $themes);
     $type_repos = array_filter($repos, function ($e) use($type) {
         return false !== stristr($e->type, $type);
     });
     $display_data = array_map(function ($e) {
         return $e = array('type' => $e->type, 'repo' => $e->repo, 'name' => $e->name, 'private' => isset($e->is_private) ? $e->is_private : false);
     }, $type_repos);
     $lock = '&nbsp;<span class="dashicons dashicons-lock"></span>';
     printf('<h2>' . esc_html__('Installed Plugins and Themes', 'github-updater') . '</h2>');
     foreach ($display_data as $data) {
         $dashicon = '<span class="dashicons dashicons-admin-plugins"></span>&nbsp;&nbsp;';
         $is_private = $data['private'] ? $lock : null;
         if (false !== strpos($data['type'], 'theme')) {
             $dashicon = '<span class="dashicons dashicons-admin-appearance"></span>&nbsp;&nbsp;';
         }
         printf('<p>' . $dashicon . $data['name'] . $is_private . '</p>');
     }
 }
Esempio n. 18
0
 public static function installPlugin($FILES)
 {
     require_once Plugin::$root_index . '/etc/pclzip.lib.php';
     $path = Plugin::$root_index . '/plugin/plugins/';
     if (empty($FILES) || !is_array($FILES)) {
         return false;
     }
     do {
         /* Upload */
         if ($_FILES['plugin']['error'] == 0) {
             if ($_FILES['plugin']['type'] !== 'application/zip' || $_FILES['plugin']['type'] !== 'application/x-zip-compressed') {
                 return false;
             }
             if (!copy($_FILES['plugin']['tmp_name'], $path . $_FILES['plugin']['name'])) {
                 return false;
             }
         }
         /* Unzip */
         $unzip = new PclZip($path . $_FILES['plugin']['name']);
         if ($unzip->extract(PCLZIP_OPT_PATH, $path) == 0) {
             return false;
         }
         /* Elimino l'archivio */
         if (file_exists($path . $_FILES['plugin']['name'])) {
             unlink($path . $_FILES['plugin']['name']);
         }
     } while (false);
     $config = '';
     self::$instance = new Plugin();
     // Nuova istanza
     $plugin = Plugin::loadPlugin(substr($_FILES['plugin']['name'], 0, -4), true);
     if (Plugin::pluginExists(substr($_FILES['plugin']['name'], 0, -4))) {
         $config = $plugin->install();
     }
     return $config;
 }
Esempio n. 19
0
 private function _init_controls()
 {
     Plugin::instance()->controls_manager->open_stack($this);
     $this->_register_controls();
 }
Esempio n. 20
0
 public function get_builder_content_for_display($post_id)
 {
     if (!get_post($post_id)) {
         return '';
     }
     // Avoid recursion
     if (get_the_ID() === (int) $post_id) {
         $content = '';
         if (Plugin::instance()->editor->is_edit_mode()) {
             $content = '<div class="elementor-alert elementor-alert-danger">' . __('Invalid Data: The Template ID cannot be the same as the currently edited template. Please choose a different one.', 'elementor') . '</div>';
         }
         return $content;
     }
     // Set edit mode as false, so don't render settings and etc. use the $is_edit_mode to indicate if we need the css inline
     $is_edit_mode = Plugin::instance()->editor->is_edit_mode();
     Plugin::instance()->editor->set_edit_mode(false);
     // Change the global post to current library post, so widgets can use `get_the_ID` and other post data
     if (isset($GLOBALS['post'])) {
         $global_post = $GLOBALS['post'];
     }
     $GLOBALS['post'] = get_post($post_id);
     $content = $this->get_builder_content($post_id, $is_edit_mode);
     // Restore global post
     if (isset($global_post)) {
         $GLOBALS['post'] = $global_post;
     } else {
         unset($GLOBALS['post']);
     }
     // Restore edit mode state
     Plugin::instance()->editor->set_edit_mode($is_edit_mode);
     return $content;
 }
Esempio n. 21
0
 /**
  * Used for renaming of sources to ensure correct directory name.
  *
  * @since WordPress 4.4.0 The $hook_extra parameter became available.
  *
  * @param $source
  * @param $remote_source
  * @param $upgrader
  * @param $hook_extra
  *
  * @return string
  */
 public function upgrader_source_selection($source, $remote_source, $upgrader, $hook_extra = null)
 {
     global $wp_filesystem, $plugins, $themes;
     $slug = null;
     $repo = null;
     $new_source = null;
     $upgrader_object = null;
     /*
      * Rename plugins.
      */
     if ($upgrader instanceof \Plugin_Upgrader) {
         $upgrader_object = Plugin::instance();
         if (isset($hook_extra['plugin'])) {
             $slug = dirname($hook_extra['plugin']);
             $new_source = trailingslashit($remote_source) . $slug;
         }
         /*
          * Pre-WordPress 4.4
          */
         if ($plugins && empty($hook_extra)) {
             foreach (array_reverse($plugins) as $plugin) {
                 $slug = dirname($plugin);
                 if (false !== stristr(basename($source), dirname($plugin))) {
                     $new_source = trailingslashit($remote_source) . dirname($plugin);
                     break;
                 }
             }
         }
         if (!$plugins && empty($hook_extra)) {
             if (isset($upgrader->skin->plugin)) {
                 $slug = dirname($upgrader->skin->plugin);
             }
             if (empty($slug) && isset($_POST['slug'])) {
                 $slug = sanitize_text_field($_POST['slug']);
             }
             $new_source = trailingslashit($remote_source) . $slug;
         }
     }
     /*
      * Rename themes.
      */
     if ($upgrader instanceof \Theme_Upgrader) {
         $upgrader_object = Theme::instance();
         if (isset($hook_extra['theme'])) {
             $slug = $hook_extra['theme'];
             $new_source = trailingslashit($remote_source) . $slug;
         }
         /*
          * Pre-WordPress 4.4
          */
         if ($themes && empty($hook_extra)) {
             foreach ($themes as $theme) {
                 $slug = $theme;
                 if (false !== stristr(basename($source), $theme)) {
                     $new_source = trailingslashit($remote_source) . $theme;
                     break;
                 }
             }
         }
         if (!$themes && empty($hook_extra)) {
             if (isset($upgrader->skin->theme)) {
                 $slug = $upgrader->skin->theme;
             }
             $new_source = trailingslashit($remote_source) . $slug;
         }
     }
     $repo = $this->get_repo_slugs($slug, $upgrader_object);
     /*
      * Not GitHub Updater plugin/theme.
      */
     if (!isset($_POST['github_updater_repo']) && empty($repo)) {
         return $source;
     }
     /*
      * Remote install source.
      */
     if (isset(self::$options['github_updater_install_repo'])) {
         $repo['repo'] = $repo['extended_repo'] = self::$options['github_updater_install_repo'];
         $new_source = trailingslashit($remote_source) . self::$options['github_updater_install_repo'];
     }
     /*
      * Directory is misnamed to start.
      * May cause deactivation.
      */
     if (!array_key_exists($slug, (array) $upgrader_object->config) && !isset(self::$options['github_updater_install_repo'])) {
         if ($upgrader instanceof \Plugin_Upgrader) {
             foreach ($upgrader_object->config as $plugin) {
                 if ($slug === dirname($plugin->slug)) {
                     $slug = $plugin->repo;
                     $new_source = trailingslashit($remote_source) . $slug;
                     break;
                 }
             }
         }
         if ($upgrader instanceof \Theme_Upgrader) {
             foreach ($upgrader_object->config as $theme) {
                 if ($slug === $theme->repo) {
                     $new_source = trailingslashit($remote_source) . $slug;
                     break;
                 }
             }
         }
     }
     /*
      * Revert extended naming if previously present.
      */
     if ($upgrader_object instanceof Plugin && (!defined('GITHUB_UPDATER_EXTENDED_NAMING') || !GITHUB_UPDATER_EXTENDED_NAMING) && $slug !== $repo['repo']) {
         $new_source = trailingslashit($remote_source) . $repo['repo'];
     }
     /*
      * Extended naming.
      * Only for plugins and not for 'master' === branch && .org hosted.
      */
     if ($upgrader_object instanceof Plugin && (defined('GITHUB_UPDATER_EXTENDED_NAMING') && GITHUB_UPDATER_EXTENDED_NAMING) && (isset($upgrader_object->config[$repo['repo']]) && !$upgrader_object->config[$repo['repo']]->dot_org || $upgrader_object->tag && 'master' !== $upgrader_object->tag || isset(self::$options['github_updater_install_repo']))) {
         $new_source = trailingslashit($remote_source) . $repo['extended_repo'];
         printf(esc_html__('Rename successful using extended name to %1$s', 'github-updater') . '&#8230;<br>', '<strong>' . $repo['extended_repo'] . '</strong>');
     }
     $wp_filesystem->move($source, $new_source);
     return trailingslashit($new_source);
 }
Esempio n. 22
0
 /**
  * Performs actual plugin metadata fetching.
  */
 public function forced_meta_update_plugins()
 {
     Plugin::$object = Plugin::instance();
     Plugin::$object->get_remote_plugin_meta();
 }
    {
        return plugin_dir_url(__FILE__);
    }
    public static function get_css_url()
    {
        return self::get_plugin_url() . 'css/';
    }
    public static function get_js_url()
    {
        return self::get_plugin_url() . 'js/';
    }
    public static function get_vendor_dir()
    {
        return self::get_plugin_dir() . 'vendor/';
    }
    private function setup_autoload()
    {
        $autoloader = self::get_vendor_dir() . 'autoload.php';
        if (file_exists($autoloader)) {
            require_once $autoloader;
        }
    }
    private function setup_actions()
    {
    }
    private function setup_filters()
    {
    }
}
Plugin::instance();
Esempio n. 24
0
function instance()
{
    return Plugin::instance();
}
Esempio n. 25
0
 public function ajax_elementor_clear_cache()
 {
     check_ajax_referer('elementor_clear_cache', '_nonce');
     Plugin::instance()->posts_css_manager->clear_cache();
     wp_send_json_success();
 }
Esempio n. 26
0
 public function enqueue_feedback_dialog_scripts()
 {
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_script('elementor-dialog', ELEMENTOR_ASSETS_URL . 'lib/dialog/dialog' . $suffix . '.js', ['jquery-ui-position'], '3.0.0', true);
     wp_register_script('elementor-admin-feedback', ELEMENTOR_ASSETS_URL . 'js/admin-feedback' . $suffix . '.js', ['underscore', 'elementor-dialog'], Plugin::instance()->get_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')]]);
 }
Esempio n. 27
0
    private static function _upgrade_v0110()
    {
        global $wpdb;
        // Fix Button widget to new sizes options
        $post_ids = $wpdb->get_col($wpdb->prepare('SELECT `post_id` FROM %1$s
						WHERE `meta_key` = \'_elementor_version\'
							AND `meta_value` = \'%2$s\';', $wpdb->postmeta, '0.3'));
        if (empty($post_ids)) {
            return;
        }
        foreach ($post_ids as $post_id) {
            $data = Plugin::instance()->db->get_plain_editor($post_id);
            $data = Plugin::instance()->db->iterate_data($data, function ($element) {
                if (empty($element['widgetType'])) {
                    return $element;
                }
                if ('button' === $element['widgetType']) {
                    $size_to_replace = ['small' => 'xs', 'medium' => 'sm', 'large' => 'md', 'xl' => 'lg', 'xxl' => 'xl'];
                    if (!empty($element['settings']['size'])) {
                        $old_size = $element['settings']['size'];
                        if (isset($size_to_replace[$old_size])) {
                            $element['settings']['size'] = $size_to_replace[$old_size];
                        }
                    }
                }
                return $element;
            });
            Plugin::instance()->db->save_editor($post_id, $data);
        }
    }
Esempio n. 28
0
 public function manager()
 {
     global $_REAL_POST;
     if ($_REAL_POST['purge']) {
         $ip = array_keys($_REAL_POST['purge']);
         $purge = $this->purge($ip[0]);
         \debug($purge);
     }
     if ($_REAL_POST['view']) {
         $host = array_keys($_REAL_POST['view']);
         $view = new \stdClass();
         $view->server = $host[0];
         $view->data = $this->get_data(500, $host[0]);
     }
     $servers = array();
     foreach ($this->memcached_servers as $memcached_server) {
         $server = new \stdClass();
         $server->host = $memcached_server;
         $server->port = '11211';
         $server->status = $this->check_status($server->host, $server->port) ? "Online" : "Offline";
         if ($server->status == "Online") {
             $mem = new \Memcache();
             $mem->addServer($memcached_server, '11211');
             $stats = $mem->getStats();
         } else {
             $stats = NULL;
         }
         //the overview stats we are interested in
         $hit_rate = @((double) $stats["get_hits"] / (double) $stats["cmd_get"] * 100);
         $hit_rate = number_format(round($hit_rate, 3));
         $miss_rate = number_format(100 - $hit_rate);
         $server->hits = $stats['get_hits'];
         $server->hitrate = $hit_rate;
         $server->missrate = $miss_rate;
         $server->misses = $stats['get_misses'];
         $server->connections = $stats['total_connections'];
         $server->objects = $stats['total_items'];
         $uptime = (int) $stats['uptime'];
         $server->uptime = number_format($uptime / 3600, 2) . ' hours';
         $server->size = (double) $stats["limit_maxbytes"] / (1024 * 1024) . " MB";
         $server->gets = $stats['cmd_get'];
         $server->sets = $stats['cmd_set'];
         $server->evictions = $stats['evictions'];
         $servers[] = $server;
     }
     //include html needed to show the page
     include Plugin::instance()->get_plugin_path() . '/includes/cache-manager.php';
 }
Esempio n. 29
0
 /**
  * Sanitize posted data.
  *
  * @since 1.0.0
  *
  * @param array $data
  *
  * @param bool $with_html_content
  *
  * @return array
  */
 private function _get_editor_data($data, $with_html_content = false)
 {
     if (isset($data['elType'])) {
         if ('widget' === $data['elType']) {
             $element_type = Plugin::instance()->widgets_manager->get_widget_types($data['widgetType']);
         } else {
             $element_type = Plugin::instance()->elements_manager->get_element_types($data['elType']);
         }
         $element_class = $element_type->get_class_name();
         /** @var Element_Base $element */
         $element = new $element_class($data);
         return $element->get_raw_data($with_html_content);
     }
     $editor_data = [];
     foreach ($data as $element_data) {
         $editor_data[] = $this->_get_editor_data($element_data, $with_html_content);
     }
     // End Section
     return $editor_data;
 }
Esempio n. 30
0
 protected function _get_child_type(array $element_data)
 {
     return Plugin::instance()->elements_manager->get_element_types('column');
 }