Changeset 1926645
- Timestamp:
- 08/18/2018 01:32:32 PM (8 years ago)
- Location:
- storefront-visual-guide
- Files:
-
- 13 added
- 5 edited
-
tags/1.1 (added)
-
tags/1.1/css (added)
-
tags/1.1/css/hooks.css (added)
-
tags/1.1/inc (added)
-
tags/1.1/inc/class-storefront-visual-guide.php (added)
-
tags/1.1/inc/class-woocommerce-visual-guide.php (added)
-
tags/1.1/inc/storefront-visual-guide-init.php (added)
-
tags/1.1/index.php (added)
-
tags/1.1/languages (added)
-
tags/1.1/readme.txt (added)
-
tags/1.1/storefront-visual-guide.php (added)
-
trunk/css/hooks.css (modified) (1 diff)
-
trunk/inc/class-storefront-visual-guide.php (modified) (4 diffs)
-
trunk/inc/class-woocommerce-visual-guide.php (modified) (2 diffs)
-
trunk/js (added)
-
trunk/js/hooks.js (added)
-
trunk/readme.txt (modified) (6 diffs)
-
trunk/storefront-visual-guide.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
storefront-visual-guide/trunk/css/hooks.css
r1923656 r1926645 1 1 .storefront-visual-hook-box, .woocommerce-visual-hook-box { 2 color: #10a1b7;3 font-weight: 500;4 font-size: 15px;5 2 background-color: #10a1b711; 6 border: 2px dashed;3 border: #10a1b7 2px dashed; 7 4 display: block; 8 padding: 6px 12px;5 padding: 12px 8px; 9 6 margin: 10px; 10 overflow: hidden; 11 word-wrap: break-word 7 text-align: center; 12 8 } 13 9 14 10 .woocommerce-visual-hook-box { 15 color: #96588a;11 border-color: #96588a; 16 12 background-color: #96588a11 17 13 } 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 35 pre.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 61 button.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 75 button.svg-inline-button.svg-bottom-toggle { 76 margin-top: 16px; 77 padding: 8px 20px; 78 } 79 80 button.svg-inline-button.svg-bottom-toggle.active { 81 background-color: #888; 82 } 83 84 button.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 106 button.svg-inline-button span { 107 display: block; 108 font-size: 20px; 109 font-weight: 700; 110 } 111 112 button#svg-show-hooked-functions.svg-inline-button span.open { 113 transform: rotate(45deg); 114 } 115 116 button.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 24 24 add_action( 'admin_notices', array( $this, 'active_notice' ) ); 25 25 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu'), 100 ); 26 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_s tylesheet') );26 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts') ); 27 27 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' ) ); 28 31 } 29 32 … … 67 70 global $wp_admin_bar; 68 71 69 if ( is_admin() ) 70 return; 72 if ( is_admin() ) { 73 return; 74 } 71 75 72 76 $wp_admin_bar->add_menu( … … 102 106 103 107 /** 104 * Enqueues Storefront Visual Guide "Hooks styles" when called.105 * 106 * @since 1. 1107 */ 108 public function enqueue_s tylesheet() {108 * Enqueues Storefront Visual Guide "Hooks styles" and "scripts" when called. 109 * 110 * @since 1.2 111 */ 112 public function enqueue_scripts() { 109 113 if ( ( 'show' == isset( $_GET['storefront_hooks'] ) ) || ( 'show' == isset( $_GET['woocommerce_hooks'] ) ) ) { 110 114 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 ); 111 116 } 112 117 } … … 150 155 } 151 156 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 153 162 154 163 do_action( 'svg_hook_content', $current_action ); 155 164 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 } 159 244 160 245 } -
storefront-visual-guide/trunk/inc/class-woocommerce-visual-guide.php
r1923656 r1926645 23 23 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu'), 100 ); 24 24 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' ) ); 25 28 } 26 29 … … 101 104 } 102 105 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 104 117 105 118 } -
storefront-visual-guide/trunk/readme.txt
r1923667 r1926645 1 === Storefront Visual Hook Guide ===1 WooCommerce=== Storefront Visual Hook Guide === 2 2 3 3 Contributors: archtkt … … 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 11 12 Find Storefront and Woo commerce hooks (action hooks) quick and easily by seeing their actual locations inside your theme.12 Find Storefront and WooCommerce hooks (action hooks) quick and easily by seeing their actual locations inside your theme. 13 13 14 14 == Description == … … 18 18 Once installed this plugin adds a drop down menu to the frontend admin bar showing different options. 19 19 20 With this plugin you can: 20 = With this plugin you can: = 21 21 22 22 1. 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. 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. 24 3. Display functions hooked in Storefront and WooCommerce action hooks. 25 4. Display remove_action() hints for hooked funtions in Storefront and WooCommerce action hooks. 24 26 25 27 This plugin is built to work with the Storefront Theme. … … 27 29 = Roadmap = 28 30 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. 31 1. Display location and funtion of Storefront frontend filters. 32 2. Include Storefront Markup to help identifying HTML containers. 33 3. Include WooCommerce Markup to help identifying HTML containers. 34 34 35 35 **Feel free to ask for new features.** … … 60 60 61 61 1. Active Storefront theme's Action Hooks in Front Page. 62 2. Active Woo commerce plugin's Action Hooks in Single Product Page.62 2. Active WooCommerce plugin's Action Hooks in Single Product Page. 63 63 3. Storefront Visual Hook Guide Menu Closeup. 64 64 65 65 == 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. 66 73 67 74 = 1.1 = … … 82 89 * Initial release 83 90 * Added: Storefront Hooks detector. 84 * Added: Woo commerce Hooks detector.91 * Added: WooCommerce Hooks detector. -
storefront-visual-guide/trunk/storefront-visual-guide.php
r1923656 r1926645 3 3 Plugin Name: Storefront Visual Hook Guide 4 4 Description: Find Storefront and Woocommerce action hooks quick and easily by seeing their actual locations inside your theme. 5 Version: 1. 15 Version: 1.2 6 6 Author: Antonio Sánchez (ARCHTKT) 7 7 Author URI: https://archtkt.com … … 37 37 // Define plugin version: SVG_PLUGIN_VERSION. 38 38 if ( ! defined( 'SVG_PLUGIN_VERSION' ) ) { 39 define( 'SVG_PLUGIN_VERSION', '1. 1.0' );39 define( 'SVG_PLUGIN_VERSION', '1.2.0' ); 40 40 } 41 41
Note: See TracChangeset
for help on using the changeset viewer.