| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpDeveloperModuleDevActions' ) ) : |
| 12 |
|
| 13 |
final class MywpDeveloperModuleDevActions extends MywpDeveloperAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'dev_actions'; |
| 16 |
|
| 17 |
static protected $priority = 1000; |
| 18 |
|
| 19 |
public static function mywp_debug_renders( $debug_renders ) { |
| 20 |
|
| 21 |
$debug_renders[ self::$id ] = array( |
| 22 |
'debug_type' => 'dev', |
| 23 |
'title' => __( 'Action Fooks' , 'my-wp' ), |
| 24 |
); |
| 25 |
|
| 26 |
return $debug_renders; |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
private static function is_mywp_function( $name ) { |
| 31 |
|
| 32 |
if( strpos( $name , 'mywp' ) !== false ) { |
| 33 |
|
| 34 |
return true; |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
if( strpos( $name , 'Mywp' ) !== false ) { |
| 39 |
|
| 40 |
return true; |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
return false; |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
private static function get_wp_actions() { |
| 49 |
|
| 50 |
global $wp_actions; |
| 51 |
|
| 52 |
return $wp_actions; |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
protected static function mywp_developer_debug() { |
| 57 |
|
| 58 |
if( ! MywpDeveloper::is_debug_item( 'debug_action' ) ) { |
| 59 |
|
| 60 |
echo esc_html( __( 'Not activated.' , 'my-wp' ) ); |
| 61 |
|
| 62 |
return false; |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
$actions = self::get_wp_actions(); |
| 67 |
|
| 68 |
echo '$wp_actions = ' . "\n"; |
| 69 |
|
| 70 |
foreach( $actions as $wp_action => $count ) { |
| 71 |
|
| 72 |
echo esc_html( ' - ' . $wp_action ) . "\n"; |
| 73 |
|
| 74 |
$filter_to_func = MywpDeveloper::get_filter_to_func( $wp_action ); |
| 75 |
|
| 76 |
if( ! empty( $filter_to_func ) ) { |
| 77 |
|
| 78 |
foreach( $filter_to_func as $func ) { |
| 79 |
|
| 80 |
echo ' '; |
| 81 |
echo esc_html( sprintf( '(%d) %s' , $func['priority'] , $func['print_format'] ) ); |
| 82 |
echo "\n"; |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
echo "\n"; |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
} |
| 93 |
|
| 94 |
protected static function mywp_debug_render() { |
| 95 |
|
| 96 |
if( ! MywpDeveloper::is_debug_item( 'debug_action' ) ) { |
| 97 |
|
| 98 |
echo esc_html( __( 'Not activated.' , 'my-wp' ) ); |
| 99 |
|
| 100 |
return false; |
| 101 |
|
| 102 |
} |
| 103 |
|
| 104 |
$actions = self::get_wp_actions(); |
| 105 |
|
| 106 |
echo '<ol class="core-actions">'; |
| 107 |
|
| 108 |
foreach( $actions as $wp_action => $count ) { |
| 109 |
|
| 110 |
$add_class = ''; |
| 111 |
|
| 112 |
if( self::is_mywp_function( $wp_action ) ) { |
| 113 |
|
| 114 |
$add_class = 'mywp-action '; |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
echo '<li class="core-action ' . esc_attr( $add_class ) . '">' . esc_html( $wp_action ); |
| 119 |
|
| 120 |
$filter_to_func = MywpDeveloper::get_filter_to_func( $wp_action ); |
| 121 |
|
| 122 |
if( ! empty( $filter_to_func ) ) { |
| 123 |
|
| 124 |
echo '<textarea readonly="readonly" class="large-text" style="height: 100px;">'; |
| 125 |
|
| 126 |
foreach( $filter_to_func as $func ) { |
| 127 |
|
| 128 |
echo esc_html( sprintf( '(%d) %s' , $func['priority'] , $func['print_format'] ) ); |
| 129 |
|
| 130 |
echo "\n"; |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
echo '</textarea>'; |
| 135 |
|
| 136 |
/* |
| 137 |
echo '<ul class="core-action-filters">'; |
| 138 |
|
| 139 |
foreach( $filter_to_func as $func ) { |
| 140 |
|
| 141 |
echo '<li class="core-action-filter">'; |
| 142 |
|
| 143 |
printf( '<strong class="priority">(%d)</strong> %s' , $func['priority'] , $func['print_format'] ); |
| 144 |
|
| 145 |
echo '</li>'; |
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
echo '</ul>'; |
| 150 |
*/ |
| 151 |
|
| 152 |
} |
| 153 |
|
| 154 |
echo '</li>'; |
| 155 |
|
| 156 |
} |
| 157 |
|
| 158 |
echo '</ol>'; |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
} |
| 163 |
|
| 164 |
MywpDeveloperModuleDevActions::init(); |
| 165 |
|
| 166 |
endif; |
| 167 |
|