Plugin Directory

Changeset 1128362


Ignore:
Timestamp:
04/05/2015 09:55:37 PM (11 years ago)
Author:
bartee
Message:

Added the possibility to retrieve shortcode information within the themes-dir

File:
1 edited

Legend:

Unmodified
Added
Removed
  • shortcode-reference/trunk/lib/ShortcodeReference.php

    r582536 r1128362  
    123123            $is_native = strpos($relative_path, 'wp-includes/');
    124124            $is_plugin = strpos($relative_path, 'wp-content/plugins/');
     125            $is_theme = strpos($relative_path, 'wp-content/themes/');
    125126            if ($is_native !== false){
    126127                return 'WordPress function';
    127             } else if ($is_plugin !== false){
     128
     129            } else if ($is_plugin !== false){
    128130                $plugin_path = explode('/',str_replace('wp-content/plugins/','',$relative_path));
    129131                return 'Plugin: '.$plugin_path[0];
    130             }
     132
     133            } else if ($is_theme !== false){
     134                $theme_path = explode('/',str_replace('wp-content/themes/','',$relative_path));
     135                return 'Theme: '.$theme_path[0];
     136            }
    131137        }
    132138        return 'PHP native';
     
    180186        if (!$this->_url){
    181187           
    182             $is_plugin = strpos($this->getReference(),'Plugin:');
     188            $is_plugin = strpos($this->getReference(),'Plugin: ');
     189            $is_theme = strpos($this->getReference(),'Theme: ');
    183190            if ($this->getReference() == 'WordPress function'){
    184 
    185191                $this->_url ='http://codex.wordpress.org/index.php?title=Special:Search&search='.$this->_shortcode.'_Shortcode';
     192
    186193            } else if ($is_plugin !== false){
    187194                $plugin_info = get_plugin_data($this->_filepath);
     
    203210                    $this->_url = 'http://www.google.com/search?q=Wordpress+'.$plugin_path.'+'.$this->_shortcode;
    204211                }
     212
     213            } else if ($is_theme !== false){
     214                // $theme_name = strtolower(str_replace('Theme: ','',$this->getReference()));
     215                $theme_root = get_theme_root();
     216                $theme = wp_get_theme(null, $theme_root);
     217                $this->_url = $theme->get('ThemeURI');
     218
    205219            } else {
    206220                $this->_url = 'http://www.php.net/'.$this->_shortcode;
Note: See TracChangeset for help on using the changeset viewer.