NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

php-console-log-page-help.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. // If this file is called directly, abort.
  3. if ( !defined( 'WPINC' ) ) {
  4. die;
  5. }
  6. /**
  7. * @func php_console_log_get_active_plugins()
  8. *
  9. * Retrieve list of active plugins from active_plugins row in the options table
  10. * of the database. Evaluate if any plugins load before PHP Console Log.
  11. *
  12. * @since 1.0.0
  13. *
  14. * @return string HTML ordered list of active plugins that load before PHP
  15. * Console Log plugin or string stating PHP Console Log is the first plugin
  16. * loaded.
  17. */
  18. function php_console_log_get_active_plugins() {
  19. $plugin_list = array();
  20. $plugins = get_option( 'active_plugins' );
  21. // get key of PHP Console Log plugin
  22. $key = array_search( PHP_CONSOLE_LOG_PLUGIN_BASENAME, $plugins );
  23. // if PHP Console Log is not the first plugin in the array
  24. if ( $key > 0 ) {
  25. // add every plugin that loads before PHP Console Log to $plugin_list array
  26. for ( $i = 0; $i < $key; $i++ ) {
  27. $plugin_list[] = $plugins[$i];
  28. }
  29. }
  30. // set default response
  31. // $return_html = '<p>None. PHP Console Log loads first.</p>';
  32. $return_html = '<p>' . esc_html__( 'None.', 'php-console-log' ) . ' PHP Console Log ' . esc_html__( 'loads first.', 'php-console-log' ) . '</p>';
  33. // build HTML ordered list of all plugins that load before PHP Console Log
  34. if ( count( $plugin_list ) ) {
  35. $return_html = '<ol>';
  36. foreach ( $plugin_list as $this_key => $plugin_path ) {
  37. // return PHP_CONSOLE_LOG_WP_PLUGIN_DIR_PATH . $plugin_path;
  38. $this_plugin_data = get_plugin_data( PHP_CONSOLE_LOG_WP_PLUGIN_DIR_PATH . $plugin_path, false, true );
  39. $return_html .= '<li>' . $this_plugin_data['Name'] . '</li>';
  40. }
  41. $return_html .= '</ol>';
  42. }
  43. echo $return_html;
  44. // printf( esc_html__( '%s', 'php-console-log' ), $return_html );
  45. }
  46. /**
  47. * @func php_console_log_page_help()
  48. *
  49. * Build and output help page.
  50. *
  51. * @since 1.0.0
  52. *
  53. */
  54. function php_console_log_page_help() {
  55. // Double check user capabilities
  56. if ( !current_user_can( 'manage_options' ) ) {
  57. return;
  58. }
  59. ?>
  60. <div id="php-console-log-help" class="wrap">
  61. <h1><?php esc_html_e( get_admin_page_title() );?></h1>
  62. <h3><?php esc_html_e( 'Important:', 'php-console-log' );?></h3>
  63. <p><?php esc_html_e( 'For security and performance on a production site, make sure to deactivate this plugin and remove all calls to', 'php-console-log' );?> <strong>do_action( 'php_console_log', '<?php esc_html_e( 'My String or Array', 'php-console-log' );?>' );</strong> <?php esc_html_e( 'from your PHP code before going live to avoid exposing your PHP variables to the public.', 'php-console-log' );?></p>
  64. <h3><?php esc_html_e( 'Plugins That Load Before PHP Console Log', 'php-console-log' );?></h3>
  65. <p><?php esc_html_e( 'PHP Console Log\'s functions are not accessible to any plugins that load before PHP Console Log is loaded. Therefore, Any plugins listed here will not be able to use PHP Console Log features.', 'php-console-log' );?></p>
  66. <code><?php php_console_log_get_active_plugins();?></code>
  67. <h3><?php esc_html_e( 'Examples:', 'php-console-log' );?></h3>
  68. <p><?php esc_html_e( 'Place the', 'php-console-log' );?> <strong>do_action( 'php_console_log', '<?php esc_html_e( 'My String or Array', 'php-console-log' );?>' );</strong> <?php esc_html_e( 'function anywhere in your WordPress plugin PHP code. The value(s) you pass into', 'php-console-log' );?> <strong>do_action( 'php_console_log', '<?php esc_html_e( 'My String or Array', 'php-console-log' );?>' );</strong> <?php esc_html_e( 'will be logged to the web console in your browser.', 'php-console-log' );?></p>
  69. <p>
  70. <strong><?php esc_html_e( 'Pass in a string:', 'php-console-log' );?></strong>
  71. </p>
  72. <p>
  73. <code>
  74. <span>$my_string = 'My String';</span>
  75. <span>do_action( 'php_console_log', $my_string );</span>
  76. </code>
  77. </p>
  78. <p>
  79. <strong><?php esc_html_e( 'Pass in an array:', 'php-console-log' );?></strong>
  80. </p>
  81. <p>
  82. <code>
  83. <span>$my_array = array(</span>
  84. <span class="tab2">'elm 1',</span>
  85. <span class="tab2">'elm 2',</span>
  86. <span class="tab1">);</span>
  87. <span>do_action( 'php_console_log', $my_array );</span>
  88. </code>
  89. </p>
  90. <p>
  91. <strong><?php esc_html_e( 'Pass in an associative array:', 'php-console-log' );?></strong>
  92. </p>
  93. <p>
  94. <code>
  95. <span>$my_array = array(</span>
  96. <span class="tab2">'key 1'=>'elm 1',</span>
  97. <span class="tab2">'key 2'=>'elm 2',</span>
  98. <span class="tab1">);</span>
  99. <span>do_action( 'php_console_log', $my_array);</span>
  100. </code>
  101. </p>
  102. <p>
  103. <strong><?php esc_html_e( 'Pass in an unlimited number of arguments nested to an unlimited depth (multi-dimensional array):', 'php-console-log' );?></strong>
  104. </p>
  105. <p>
  106. <code>
  107. <span>$my_array = array(</span>
  108. <span class="tab2">'My String 1',</span>
  109. <span class="tab2">'My String 2',</span>
  110. <span class="tab2">array(</span>
  111. <span class="tab3">'elm 1',</span>
  112. <span class="tab3">'elm 2',</span>
  113. <span class="tab2">),</span>
  114. <span class="tab2">'My String 3',</span>
  115. <span class="tab2">array(</span>
  116. <span class="tab3">'key 1'=>'elm 1',</span>
  117. <span class="tab3">'key 2'=>'elm 2',</span>
  118. <span class="tab3">'key 3' => array(</span>
  119. <span class="tab4">'key 3a' => 'elm 3a',</span>
  120. <span class="tab4">'key 3b' => 'elm 3b',</span>
  121. <span class="tab3">),</span>
  122. <span class="tab2">),</span>
  123. <span class="tab2">'My String 4'</span>
  124. <span class="tab1">);</span>
  125. <span>do_action( 'php_console_log', $my_array);</span>
  126. </code>
  127. </p>
  128. <h3><?php esc_html_e( 'Opening Web Console in your browser:', 'php-console-log' );?></h3>
  129. <div class="troubleshooting">
  130. <ul>
  131. <li>
  132. <p>
  133. <strong>Chrome:</strong><br>
  134. <?php esc_html_e( 'Press Command + Option + J (Mac) or Control + Shift + J (Windows, Linux, Chrome OS) to jump straight into the Console panel.', 'php-console-log' );?>
  135. </p>
  136. <p><?php esc_html_e( 'source', 'php-console-log' );?>: <a href="https://developers.google.com/web/tools/chrome-devtools/open#console">https://developers.google.com/web/tools/chrome-devtools/open#console</a></p>
  137. </li>
  138. <li>
  139. <p>
  140. <strong>Firefox:</strong><br>
  141. <?php esc_html_e( 'Select Web Console from the Web Developer submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on Mac OS X).', 'php-console-log' );?>
  142. </p>
  143. <p><strong><?php esc_html_e( 'OR', 'php-console-log' );?></strong></p>
  144. <p><?php esc_html_e( 'Press the Ctrl + Shift + K (Command + Option + K on OS X) keyboard shortcut.', 'php-console-log' );?></p>
  145. <p><?php esc_html_e( 'source', 'php-console-log' );?>: <a href="https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Opening_the_Web_Console">https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Opening_the_Web_Console</a></p>
  146. </li>
  147. <li>
  148. <p>
  149. <strong>Safari:</strong><br>
  150. <?php esc_html_e( 'Select Develop menu in the menu bar, choose Show JavaScript Console.', 'php-console-log' );?>
  151. </p>
  152. <p><?php esc_html_e( 'If you don\'t see the Develop menu in the menu bar, choose Safari > Preferences, click Advanced, then select "Show Develop menu in menu bar".', 'php-console-log' );?></p>
  153. <p><?php esc_html_e( 'source', 'php-console-log' );?>: <a href="https://support.apple.com/guide/safari-developer/develop-menu-dev39df999c1/mac">https://support.apple.com/guide/safari-developer/develop-menu-dev39df999c1/mac</a></p>
  154. </li>
  155. </ul>
  156. </div>
  157. <h3><?php esc_html_e( 'Troubleshooting:', 'php-console-log' );?></h3>
  158. <p><?php esc_html_e( 'The most common reasons that cause PHP Console Log to fail when logging your information to the web console are:', 'php-console-log' );?></p>
  159. <div class="troubleshooting">
  160. <ol>
  161. <li>
  162. <p>
  163. <strong><?php esc_html_e( 'Cause:', 'php-console-log' );?></strong><br>
  164. <?php esc_html_e( 'The PHP Console log plugin is not activated.', 'php-console-log' );?>
  165. </p>
  166. <p>
  167. <strong><?php esc_html_e( 'Solution:', 'php-console-log' );?></strong><br>
  168. <?php esc_html_e( 'Activate the PHP Console Log Plugin.', 'php-console-log' );?>
  169. </p>
  170. </li>
  171. <li>
  172. <p>
  173. <strong><?php esc_html_e( 'Cause:', 'php-console-log' );?></strong><br>
  174. <?php esc_html_e( 'Another plugin has changed the order in which your plugins load. Making the PHP Console Log functions not available yet.', 'php-console-log' );?>
  175. </p>
  176. <p>
  177. <strong><?php esc_html_e( 'Solution:', 'php-console-log' );?></strong><br>
  178. <?php esc_html_e( 'PHP Console Log updates the order in which plugins are loaded any time a plugin is activated or deactivated. However, it is still possible for other plugins to change the order in which plugins load afterwards. Deactivate any plugins that change the order in which your plugins load.', 'php-console-log' );?>
  179. </p>
  180. </li>
  181. <li>
  182. <p>
  183. <strong><?php esc_html_e( 'Cause:', 'php-console-log' );?></strong><br>
  184. <strong>do_action( 'php_console_log', '<?php esc_html_e( 'My String or Array', 'php-console-log' );?>' );</strong> <?php esc_html_e( 'was called inside a block of code that was not run.', 'php-console-log' );?>
  185. </p>
  186. <p>
  187. <strong><?php esc_html_e( 'Solution:', 'php-console-log' );?></strong><br>
  188. <?php esc_html_e( 'Make sure the function you called', 'php-console-log' );?> <strong>do_action( 'php_console_log', '<?php esc_html_e( 'My String or Array', 'php-console-log' );?>' );</strong> <?php esc_html_e( 'in is run via an action or filter hook such as:', 'php-console-log' );?> <strong>add_action( 'init', 'my_function' );</strong> <?php esc_html_e( 'Or call', 'php-console-log' );?> <strong>do_action( 'php_console_log', '<?php esc_html_e( 'My String or Array', 'php-console-log' );?>' );</strong> <?php esc_html_e( 'outside of any other functions in a file that you know is run.', 'php-console-log' );?>
  189. </p>
  190. </li>
  191. <li>
  192. <p>
  193. <strong><?php esc_html_e( 'Cause:', 'php-console-log' );?></strong><br>
  194. <?php esc_html_e( 'PHP throws errors.', 'php-console-log' );?> <strong><?php esc_html_e( 'Side Note:', 'php-console-log' );?></strong> <?php esc_html_e( 'Make sure you are using', 'php-console-log' );?> <strong>define( 'WP_DEBUG', true );</strong> <?php esc_html_e( 'in your wp-config.php file so you can see PHP errors.', 'php-console-log' );?>
  195. </p>
  196. <p>
  197. <strong><?php esc_html_e( 'Solution:', 'php-console-log' );?></strong><br>
  198. <?php esc_html_e( 'Fix the error that PHP is showing you. Then try again.', 'php-console-log' );?>
  199. </p>
  200. </li>
  201. </ol>
  202. </div>
  203. </div>
  204. <?php
  205. }