Ejemplo n.º 1
0
 /**
  * Creates plugin specific settings for the JavaScript variable
  * addthis_plugin_info
  *
  * @return array an associative array
  */
 public function getAddThisPluginInfo()
 {
     $pluginInfo = array();
     $pluginInfo = array();
     $pluginInfo['info_status'] = 'enabled';
     $pluginInfo['cms_name'] = $this->getCmsName();
     $pluginInfo['cms_version'] = $this->getCmsVersion();
     $pluginInfo['plugin_name'] = $this->name;
     $pluginInfo['plugin_version'] = $this->getVersion();
     if ($this->globalOptionsObject->inAnonymousMode()) {
         $pluginInfo['plugin_mode'] = $this->getCmsName();
     } else {
         $pluginInfo['plugin_mode'] = 'AddThis';
     }
     $pluginInfo['anonymous_profile_id'] = $this->globalOptionsObject->getAnonymousProfileId();
     if ($this->globalOptionsObject->checkForEditPermissions(false)) {
         $pluginInfo['php_version'] = phpversion();
         $pluginInfo['cms_version'] = $this->getCmsVersion();
     }
     // post specific stuff that requires wp_query
     global $wp_query;
     if (isset($wp_query)) {
         $pluginInfo['page_info']['template'] = AddThisTool::currentTemplateType();
         if (isset($wp_query->query_vars['post_type'])) {
             $pluginInfo['page_info']['post_type'] = $wp_query->query_vars['post_type'];
         }
     }
     // post specific meta box selection
     global $post;
     if (is_object($post) && $post instanceof WP_Post && !empty($post->ID)) {
         $at_flag = get_post_meta($post->ID, '_at_widget', true);
         if ($at_flag === '0') {
             $pluginInfo['sharing_enabled_on_post_via_metabox'] = false;
         } else {
             $pluginInfo['sharing_enabled_on_post_via_metabox'] = true;
         }
     }
     return $pluginInfo;
 }
 /**
  * This must be public as it's used in the feature object with this tool
  *
  * This takes configs and adds default values where not present
  *
  * @param array $configs An associative array of values input for this
  * tools' settings
  *
  * @return array An associative array of settings specific to this tool
  *               with added defaults where not already present.
  */
 public function addDefaultConfigs($configs)
 {
     $configs = parent::addDefaultConfigs($configs);
     if (empty($configs['services'])) {
         $configs['services'] = new stdClass();
     }
     return $configs;
 }
 /**
  * Builds the class used for sharing buttons above and below content on
  * pages, posts, categories, archives and the homepage
  *
  * @param string $location Is this for a sharing button above or below
  * content/excerpts?
  * @param array  $track    Optional. Used by reference. If the
  * filter changes the value in any way the filter's name will be pushed
  *
  * @return string a class
  */
 public function getClassForTypeAndLocation($location = 'above', &$track = false)
 {
     $pageTypeClean = AddThisTool::currentTemplateType();
     switch ($pageTypeClean) {
         case 'home':
             $appendClass = 'post-homepage';
             break;
         case 'archives':
             $appendClass = 'post-arch-page';
             break;
         case 'categories':
             $appendClass = 'post-cat-page';
             break;
         case 'pages':
             $appendClass = 'post-page';
             break;
         case 'posts':
             $appendClass = 'post';
             break;
         default:
             $appendClass = false;
     }
     if ($location == 'above') {
         $toolClass = 'at-above-' . $appendClass;
         $filterName = $this->filterNamePrefix . 'above_tool';
     } else {
         $toolClass = 'at-below-' . $appendClass;
         $filterName = $this->filterNamePrefix . 'below_tool';
     }
     if (!$appendClass) {
         $toolClass = false;
     }
     $toolClass = $this->applyToolClassFilters($toolClass, $location, $track);
     return $toolClass;
 }
 /**
  * Builds the class used for recommended content below content on posts.
  *
  * @param string $location Is this for a sharing button above or below
  * content/excerpts?
  * @param array  $track    Optional. Used by reference. If the
  * filter changes the value in any way the filter's name will be pushed
  *
  * @return string a class
  */
 public function getClassForTypeAndLocation($location = 'above', &$track = false)
 {
     $pageTypeClean = AddThisTool::currentTemplateType();
     if ($pageTypeClean == 'posts') {
         $toolClass = 'at-below-post-recommended';
     } else {
         $toolClass = false;
     }
     $toolClass = $this->applyToolClassFilters($toolClass, $location, $track);
     return $toolClass;
 }