php - WordPress - get shortcode attribute name -


please tell how retrieve available attributes of shortcode.

i have available shortcode won't show attribute name

global $shortcode_tags; print_r($shortcode_tags); 

someone told me use php reflection api..

a working plugin code shortcode attribute:

class shortcodereference {      /**      * shortcode      * @var string      */     private $_shortcode;      /**      * @var reflectionfunction      */     private $_function_reflection;      /**      * @var string      */     private $_filepath;      /**      * flat doccomments.      * @var string      */     private $_description;      /**      * @var array      */     private $_attributes;      /**      * @var string      */     private $_function_name;      /**      * tags found in documentation      * @var array      */     private $_known_tags;      /**      * - function name      * - attribute(s)      * - plugin or core      */      public function __construct($shortcode){         global $shortcode_tags;          if (!key_exists($shortcode, $shortcode_tags)){             return false;         }          $this->_shortcode = $shortcode;         $this->_function_name = $shortcode_tags[$shortcode];          if (is_string($this->_function_name)){             $this->_function_reflection = new reflectionfunction($this->_function_name);         } else if (is_array($this->_function_name)) {             $this->_function_reflection = new reflectionmethod ($this->_function_name[0],$this->_function_name[1]);         }     }      /**      * if no description function found, parse doccomment of function , return string.       */     public function getdescription(){         if ($this->_description == ''){             $this->_known_tags = array();             $desc = $this->_function_reflection->getdoccomment();             $parsed_desc = '';             if ($desc){                 $matches = preg_split('/\n/',$desc);                 $start_pattern = '/w*\/\*\*w*/';                 foreach ($matches $match) {                     if (preg_match($start_pattern, $match,$submatch)){                         // skip                     } else if (preg_match('/w*\*\//',$match,$submatch)){                         $offset = strpos($match,'*/')-1;                         $final_line.= trim(substr($match,0,-$offset)).' ';                         if ($final_line != ''){                             $parsed_desc .= $final_line;                         }                     } else if (preg_match('/w*\*/',$match,$submatch)){                         if (preg_match('/@/',$match,$submatch)){                             $offset = strpos($match,'@')+1;                             $tag = trim(substr($match,$offset,strlen($match)-$offset));                             $this->addtagfromstring($tag);                         } else {                             $offset = strpos($match,'*')+1;                             $parsed_desc .= trim(substr($match,$offset,strlen($match)-$offset)).'         ';                         }                     }                 }             }             if ($parsed_desc == ''){                 $parsed_desc = __('no documentation found. ','shortcode reference');             }             $this->_description = $parsed_desc;         }         return $this->_description;     }      /**      * find targeted function defined.      * @return string      */     public function getreference(){         $absolute_path = $this->_function_reflection->getfilename();         $this->_filepath = $absolute_path;         if (strpos($absolute_path, abspath)>=0){             /**              * yay, it's wordpress!              */             $relative_path = str_replace(abspath,'',$absolute_path);             $is_native = strpos($relative_path, 'wp-includes/');             $is_plugin = strpos($relative_path, 'wp-content/plugins/');             if ($is_native !== false){                 return 'wordpress function';             } else if ($is_plugin !== false){                 $plugin_path = explode('/',str_replace('wp-content/plugins/','',$relative_path));                 return 'plugin: '.$plugin_path[0];             }         }         return 'php native';     }      /**      * retrieve absolute file path      *      * @return string      */     public function getfilepath(){         return $this->_filepath;     }      /**      * options function      *       * @return array      */     public function getparameters(){         $options = $this->_function_reflection->getparameters();     }      /**      * parse string tag      * @param string $string      */     private function addtagfromstring($string){         $tag = explode(' ',$string);         $tagname = array_shift($tag);         $this->_known_tags[$tagname] = implode(' ',$tag);     }      /**      * tags current documentation      */     public function gettags(){         if (!is_array($this->_known_tags)){             $desc = $this->getdescription();         }         return $this->_known_tags;     }      /**      * url can find more information shortcode.      *       * @return url      */     public function geturl(){          if (!$this->_url){              $is_plugin = strpos($this->getreference(),'plugin:');             if ($this->getreference() == 'wordpress function'){                  $this->_url ='http://codex.wordpress.org/index.php?title=special:search&search='.$this->_shortcode.'_shortcode';             } else if ($is_plugin !== false){                 $plugin_info = get_plugin_data($this->_filepath);                  if (is_array($plugin_info) && key_exists('pluginuri',$plugin_info)){                     /**                      * if can find plugin-url, use                      */                     $this->_url = $plugin_info['pluginuri'];                 } else if (is_array($plugin_info) && key_exists('authoruri',$plugin_info)){                     /**                      * else use author-uri                      */                     $this->_url = $plugin_info['authoruri'];                 } else {                     /**                      * if else fails, google friend                      */                     $this->_url = 'http://www.google.com/search?q=wordpress+'.$plugin_path.'+'.$this->_shortcode;                 }             } else {                 $this->_url = 'http://www.php.net/'.$this->_shortcode;             }         }         return $this->_url;     } } 

attributes of shortcodes set dynamically. attribute can created , passed function. there no way them unless new/custom method of tracking them created , used shortcodes want attributes of.

http://codex.wordpress.org/shortcode_api

edit: seems not want attributes of shortcode, rather description , details.

if have plugin, open , notepad , find line want.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -