Plugin Directory

Changeset 1926645


Ignore:
Timestamp:
08/18/2018 01:32:32 PM (8 years ago)
Author:
archtkt
Message:

Plugin version 1.2 update

Location:
storefront-visual-guide
Files:
13 added
5 edited

Legend:

Unmodified
Added
Removed
  • storefront-visual-guide/trunk/css/hooks.css

    r1923656 r1926645  
    11.storefront-visual-hook-box, .woocommerce-visual-hook-box {
    2   color: #10a1b7;
    3   font-weight: 500;
    4   font-size: 15px;
    52  background-color: #10a1b711;
    6   border: 2px dashed;
     3  border: #10a1b7 2px dashed;
    74  display: block;
    8   padding: 6px 12px;
     5  padding: 12px 8px;
    96  margin: 10px;
    10   overflow: hidden;
    11   word-wrap: break-word
     7  text-align: center;
    128}
    139
    1410.woocommerce-visual-hook-box {
    15   color: #96588a;
     11  border-color: #96588a;
    1612  background-color: #96588a11
    1713}
     14
     15.storefront-visual-hook-box h3, .woocommerce-visual-hook-box h3 {
     16  display: inline;
     17  color: #10a1b7;
     18  font-size: 16px;
     19  font-weight: 700;
     20  word-wrap: break-word;
     21  letter-spacing: 0.8px;
     22  margin: 12px;
     23  transition: all 0.3s ease-in-out;
     24}
     25
     26.woocommerce-visual-hook-box h3 {
     27  color: #96588a;
     28}
     29
     30#visual-hook-box.active h3 {
     31  font-size: 18px;
     32  text-transform: uppercase;
     33}
     34
     35pre.svg-hooked-functions {
     36  display: none;
     37  padding: 16px;
     38  background-color: #fff;
     39  border: #bbb solid 1px;
     40}
     41
     42.svg-hooked-function {
     43  font-size: 17px;
     44  line-height: 2;
     45  letter-spacing: 0.5px;
     46}
     47
     48.svg-hooked-function span {
     49  margin: 0 6px 0 12px;
     50}
     51
     52.svg-hooked-functions.active .svg-hooked-function {
     53  font-size: 14px;
     54  line-height: 2.45;
     55}
     56
     57.svg-hooked-functions.active .svg-hooked-function span {
     58  margin: 0;
     59}
     60
     61button.svg-inline-button {
     62  display: inline-block;
     63  cursor: pointer;
     64  color: #444;
     65  padding: 2px 13px;
     66  background-color: #fff;
     67  border-radius: 5px;
     68  -webkit-box-shadow: #00000088 0 4px 10px -4px;
     69  box-shadow: #00000088 0 4px 10px -4px;
     70  -webkit-transition: all 0.15s ease-in-out;
     71  transition: all 0.15s ease-in-out;
     72  margin: 6px;
     73}
     74
     75button.svg-inline-button.svg-bottom-toggle {
     76  margin-top: 16px;
     77  padding: 8px 20px;
     78}
     79
     80button.svg-inline-button.svg-bottom-toggle.active {
     81  background-color: #888;
     82}
     83
     84button.svg-inline-button.svg-bottom-toggle.active:hover {
     85  background-color: #444;
     86}
     87
     88.storefront-visual-hook-box button.svg-bottom-toggle {
     89  color: #fff;
     90  background-color: #10a1b7bb;
     91}
     92
     93.woocommerce-visual-hook-box button.svg-bottom-toggle {
     94  color: #fff;
     95  background-color: #96588abb;
     96}
     97
     98.storefront-visual-hook-box .svg-bottom-toggle:hover {
     99  background-color: #10a1b7;
     100}
     101
     102.woocommerce-visual-hook-box .svg-bottom-toggle:hover {
     103  background-color: #96588a;
     104}
     105
     106button.svg-inline-button span {
     107  display: block;
     108  font-size: 20px;
     109  font-weight: 700;
     110}
     111
     112button#svg-show-hooked-functions.svg-inline-button span.open {
     113  transform: rotate(45deg);
     114}
     115
     116button.svg-inline-button:hover {
     117  background-color: #eee;
     118  -webkit-box-shadow: #00000044 0 1px 4px -2px;
     119  box-shadow: #00000044 0 1px 4px -2px;
     120}
  • storefront-visual-guide/trunk/inc/class-storefront-visual-guide.php

    r1923660 r1926645  
    2424    add_action( 'admin_notices', array( $this, 'active_notice' ) );
    2525    add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu'), 100 );
    26     add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_stylesheet') );
     26    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts') );
    2727    add_action( 'get_header', array( $this, 'hooker') );
     28    add_action( 'svg_hook_button', array( $this, 'hooked_functions_button' ) );
     29    add_action( 'svg_hook_content', array( $this, 'action_hooks_content') );
     30    add_action( 'svg_hook_toggle', array( $this, 'remove_hooked_functions_toggle' ) );
    2831  }
    2932
     
    6770        global $wp_admin_bar;
    6871
    69         if ( is_admin() )
    70             return;
     72        if ( is_admin() ) {
     73      return;
     74    }
    7175
    7276        $wp_admin_bar->add_menu(
     
    102106
    103107  /**
    104    * Enqueues Storefront Visual Guide "Hooks styles" when called.
    105    *
    106    * @since   1.1
    107    */
    108   public function enqueue_stylesheet() {
     108   * Enqueues Storefront Visual Guide "Hooks styles" and "scripts" when called.
     109   *
     110   * @since   1.2
     111   */
     112  public function enqueue_scripts() {
    109113    if ( ( 'show' == isset( $_GET['storefront_hooks'] ) ) || ( 'show' == isset( $_GET['woocommerce_hooks'] ) ) ) {
    110114      wp_enqueue_style( 'svg_hooks', plugins_url( 'css/hooks.css', plugin_basename( SVG_PLUGIN_PATH ) ), array(), SVG_PLUGIN_VERSION );
     115      wp_enqueue_script( 'svg_hooks', plugins_url( 'js/hooks.js', plugin_basename( SVG_PLUGIN_PATH ) ), array( 'jquery' ), SVG_PLUGIN_VERSION, true );
    111116    }
    112117    }
     
    150155    }
    151156
    152     ?> <div class="storefront-visual-hook-box" data-svg-hook-box="<?php echo $current_action; ?>"><?php echo $current_action;
     157    ?> <div id="visual-hook-box" class="storefront-visual-hook-box" data-svg-hook-box="<?php echo $current_action; ?>"><h3><?php echo $current_action; ?></h3><?php
     158
     159    do_action( 'svg_hook_button', $current_action );
     160
     161    ?><pre class="svg-hooked-functions"><?php
    153162
    154163    do_action( 'svg_hook_content', $current_action );
    155164
    156     ?> </div> <?php
    157 
    158   }
     165    do_action( 'svg_hook_toggle', $current_action );
     166
     167    ?> </pre></div> <?php
     168
     169  }
     170
     171  public static function hooked_functions_button( $current_action ) {
     172    global $wp_filter;
     173    if ( isset( $wp_filter[ $current_action ] ) ) :
     174      ?><button id="svg-show-hooked-functions" class="svg-inline-button" title="<?php _e( 'Toggle hooked funtions', 'storefront-visual-guide' ); ?>"><span>+</span></button><?php
     175    endif;
     176  }
     177
     178  public static function remove_hooked_functions_toggle( $current_action ) {
     179    global $wp_filter;
     180    if ( isset( $wp_filter[ $current_action ] ) ) :
     181      ?><button id="svg-toggle-remove-functions" class="svg-inline-button svg-bottom-toggle" title="<?php _e( 'Toggle remove_action hint', 'storefront-visual-guide' ); ?>" data-svg-action-hook="<?php echo $current_action; ?>"><?php _e( 'Remove_action hint', 'storefront-visual-guide' ); ?></button><?php
     182    endif;
     183  }
     184
     185  public static function action_hooks_content( $current_action ) {
     186    global $wp_filter;
     187    if ( isset( $wp_filter[ $current_action ] ) ) :
     188      foreach ( $wp_filter[ $current_action ] as $priority => $callbacks ) {
     189        foreach ( $callbacks as $callback ) {
     190          $callback = self::populate_callback( $callback );
     191          if ( isset( $callback['component'] ) ) {
     192            $components[ $callback['component']->name ] = $callback['component']->name;
     193          }
     194          ?><code class="svg-hooked-function"><?php
     195          do_action( 'svg_hook_function_opening', $current_action );
     196          ?><span class="svg-function-name" title="<?php _e( 'Function', 'storefront-visual-guide' ); ?>">'<?php echo $callback['name']; ?>'</span>, <span class="svg-function-priority" title="<?php _e( 'Priority', 'storefront-visual-guide' ); ?>"><?php
     197          echo $priority;
     198          ?></span><?php
     199          do_action( 'svg_hook_function_closing' );
     200          ?></code><br><?php
     201        }
     202      }
     203    endif;
     204  }
     205
     206  public static function populate_callback( array $callback ) {
     207        if ( is_string( $callback['function'] ) and ( false !== strpos( $callback['function'], '::' ) ) ) {
     208            $callback['function'] = explode( '::', $callback['function'] );
     209        }
     210        try {
     211            if ( is_array( $callback['function'] ) ) {
     212                if ( is_object( $callback['function'][0] ) ) {
     213                    $class  = get_class( $callback['function'][0] );
     214                    $access = '::';
     215                } else {
     216                    $class  = $callback['function'][0];
     217                    $access = ' -> ';
     218                }
     219                $callback['name'] = 'Class->' . $class . $access . $callback['function'][1] . '()';
     220                $ref = new ReflectionMethod( $class, $callback['function'][1] );
     221            } elseif ( is_object( $callback['function'] ) ) {
     222                if ( is_a( $callback['function'], 'Closure' ) ) {
     223                    $ref  = new ReflectionFunction( $callback['function'] );
     224                    if ( 0 === strpos( $file, '/' ) ) {
     225                        $file = basename( $ref->getFileName() );
     226                    }
     227                    $callback['name'] = sprintf( __( 'Closure on line %1$d of %2$s', 'query-monitor' ), $ref->getStartLine(), $file );
     228                } else {
     229                    $class = get_class( $callback['function'] );
     230                    $callback['name'] = $class . '->__invoke';
     231                    $ref = new ReflectionMethod( $class, '__invoke' );
     232                }
     233            } else {
     234                $callback['name'] = $callback['function'];
     235                $ref = new ReflectionFunction( $callback['function'] );
     236            }
     237            $callback['line'] = $ref->getStartLine();
     238            $name = trim( $ref->getName() );
     239        } catch ( ReflectionException $e ) {
     240            $callback['error'] = new WP_Error( 'reflection_exception', $e->getMessage() );
     241        }
     242        return $callback;
     243    }
    159244
    160245}
  • storefront-visual-guide/trunk/inc/class-woocommerce-visual-guide.php

    r1923656 r1926645  
    2323    add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu'), 100 );
    2424    add_action( 'get_header', array( $this, 'woocommerce_hooker') );
     25    add_action( 'svg_woo_hook_button', array( 'Storefront_Visual_Guide', 'hooked_functions_button' ) );
     26    add_action( 'svg_woo_hook_content', array( 'Storefront_Visual_Guide', 'action_hooks_content') );
     27    add_action( 'svg_woo_hook_toggle', array( 'Storefront_Visual_Guide', 'remove_hooked_functions_toggle' ) );
    2528  }
    2629
     
    101104    }
    102105
    103     echo '<div class="woocommerce-visual-hook-box" data-svg-hook-box="' . $current_action . '">' . $current_action . '</div>';
     106    ?> <div id="visual-hook-box" class="woocommerce-visual-hook-box" data-svg-hook-box="<?php echo $current_action; ?>"><h3><?php echo $current_action; ?></h3><?php
     107
     108    do_action( 'svg_woo_hook_button', $current_action );
     109
     110    ?><pre class="svg-hooked-functions"><?php
     111
     112    do_action( 'svg_woo_hook_content', $current_action );
     113
     114    do_action( 'svg_woo_hook_toggle', $current_action );
     115
     116    ?> </pre></div> <?php
    104117
    105118  }
  • storefront-visual-guide/trunk/readme.txt

    r1923667 r1926645  
    1 === Storefront Visual Hook Guide ===
     1WooCommerce=== Storefront Visual Hook Guide ===
    22
    33Contributors: archtkt
     
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Find Storefront and Woocommerce hooks (action hooks) quick and easily by seeing their actual locations inside your theme.
     12Find Storefront and WooCommerce hooks (action hooks) quick and easily by seeing their actual locations inside your theme.
    1313
    1414== Description ==
     
    1818Once installed this plugin adds a drop down menu to the frontend admin bar showing different options.
    1919
    20 With this plugin you can:
     20= With this plugin you can: =
    2121
    22221. Show Storefront Hooks: Select this option to see the Storefront theme's hooks in their actual locations.
    23 2. Show Woocommerce Hooks: Select this option to see the Woocommerce plugin's hooks in their actual locations on your current theme. WooCommerce plugin must be active for you to see this option.
     232. Show WooCommerce Hooks: Select this option to see the WooCommerce plugin's hooks in their actual locations on your current theme. WooCommerce plugin must be active for you to see this option.
     243. Display functions hooked in Storefront and WooCommerce action hooks.
     254. Display remove_action() hints for hooked funtions in Storefront and WooCommerce action hooks.
    2426
    2527This plugin is built to work with the Storefront Theme.
     
    2729= Roadmap =
    2830
    29 1. Display functions hooked in Storefront action hooks.
    30 2. Display functions hooked in Woocommerce action hooks.
    31 3. Display location and funtion of Storefront frontend filters.
    32 4. Include Storefront Markup to help identifying HTML containers.
    33 5. Include Woocommerce Markup to help identifying HTML containers.
     311. Display location and funtion of Storefront frontend filters.
     322. Include Storefront Markup to help identifying HTML containers.
     333. Include WooCommerce Markup to help identifying HTML containers.
    3434
    3535**Feel free to ask for new features.**
     
    6060
    61611. Active Storefront theme's Action Hooks in Front Page.
    62 2. Active Woocommerce plugin's Action Hooks in Single Product Page.
     622. Active WooCommerce plugin's Action Hooks in Single Product Page.
    63633. Storefront Visual Hook Guide Menu Closeup.
    6464
    6565== Changelog ==
     66
     67= 1.2 =
     68* Added hooked functions display button.
     69* Display functions hooked in Storefront action hooks.
     70* Display functions hooked in WooCommerce action hooks.
     71* Added `remove_action` display button.
     72* Added `remove_action` adaption to classes.
    6673
    6774= 1.1 =
     
    8289* Initial release
    8390* Added: Storefront Hooks detector.
    84 * Added: Woocommerce Hooks detector.
     91* Added: WooCommerce Hooks detector.
  • storefront-visual-guide/trunk/storefront-visual-guide.php

    r1923656 r1926645  
    33Plugin Name: Storefront Visual Hook Guide
    44Description: Find Storefront and Woocommerce action hooks quick and easily by seeing their actual locations inside your theme.
    5 Version: 1.1
     5Version: 1.2
    66Author: Antonio Sánchez (ARCHTKT)
    77Author URI: https://archtkt.com
     
    3737// Define plugin version: SVG_PLUGIN_VERSION.
    3838if ( ! defined( 'SVG_PLUGIN_VERSION' ) ) {
    39     define( 'SVG_PLUGIN_VERSION', '1.1.0' );
     39    define( 'SVG_PLUGIN_VERSION', '1.2.0' );
    4040}
    4141
Note: See TracChangeset for help on using the changeset viewer.