@@ -6,166 +6,166 @@ |
||
| 6 | 6 | * @package Shortcodely |
| 7 | 7 | */ |
| 8 | 8 | function shortcodely_show_shortcode_widget_possibilities() { |
| 9 | - //function to show the widget possibilities |
|
| 10 | - global $_wp_sidebars_widgets; |
|
| 11 | - |
|
| 12 | - $sidebars_widgets = $_wp_sidebars_widgets; |
|
| 13 | - ksort( $sidebars_widgets ); // push inactive down the bottom of the list |
|
| 14 | - $text = '<ul>'; |
|
| 15 | - foreach ( $sidebars_widgets as $sidebarid => $sidebar ) { |
|
| 16 | - if ( is_array( $sidebar ) ) { |
|
| 17 | - $text .= '<li><em>[do_widget_area ' . $sidebarid . ']</em><ul>'; |
|
| 18 | - foreach ( $sidebar as $i => $w ) { |
|
| 19 | - $text .= '<li>'; |
|
| 20 | - $text .= '[do_widget id="' . $w . '"]'; |
|
| 21 | - $text .= '</li>'; |
|
| 22 | - } |
|
| 23 | - $text .= '</ul></li>'; |
|
| 24 | - } |
|
| 25 | - } |
|
| 26 | - $text .= '</ul>'; |
|
| 27 | - |
|
| 28 | - return $text; |
|
| 9 | + //function to show the widget possibilities |
|
| 10 | + global $_wp_sidebars_widgets; |
|
| 11 | + |
|
| 12 | + $sidebars_widgets = $_wp_sidebars_widgets; |
|
| 13 | + ksort( $sidebars_widgets ); // push inactive down the bottom of the list |
|
| 14 | + $text = '<ul>'; |
|
| 15 | + foreach ( $sidebars_widgets as $sidebarid => $sidebar ) { |
|
| 16 | + if ( is_array( $sidebar ) ) { |
|
| 17 | + $text .= '<li><em>[do_widget_area ' . $sidebarid . ']</em><ul>'; |
|
| 18 | + foreach ( $sidebar as $i => $w ) { |
|
| 19 | + $text .= '<li>'; |
|
| 20 | + $text .= '[do_widget id="' . $w . '"]'; |
|
| 21 | + $text .= '</li>'; |
|
| 22 | + } |
|
| 23 | + $text .= '</ul></li>'; |
|
| 24 | + } |
|
| 25 | + } |
|
| 26 | + $text .= '</ul>'; |
|
| 27 | + |
|
| 28 | + return $text; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /*-----------------------------------*/ |
| 32 | 32 | function shortcodely_get_widgets_sidebar( $wid ) { |
| 33 | - /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. |
|
| 33 | + /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. |
|
| 34 | 34 | take the first one that matches */ |
| 35 | - global $_wp_sidebars_widgets; |
|
| 36 | - |
|
| 37 | - foreach ( $_wp_sidebars_widgets as $sidebarid => $sidebar ) { |
|
| 38 | - if ( is_array( $sidebar ) ) { // ignore the 'array version' sidebarid that isnt actually a sidebar |
|
| 39 | - foreach ( $sidebar as $i => $w ) { |
|
| 40 | - if ( $w == $wid ) { |
|
| 41 | - return $sidebarid; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - return false; // widget id not in any sidebar |
|
| 35 | + global $_wp_sidebars_widgets; |
|
| 36 | + |
|
| 37 | + foreach ( $_wp_sidebars_widgets as $sidebarid => $sidebar ) { |
|
| 38 | + if ( is_array( $sidebar ) ) { // ignore the 'array version' sidebarid that isnt actually a sidebar |
|
| 39 | + foreach ( $sidebar as $i => $w ) { |
|
| 40 | + if ( $w == $wid ) { |
|
| 41 | + return $sidebarid; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return false; // widget id not in any sidebar |
|
| 48 | 48 | } |
| 49 | 49 | /*-----------------------------------*/ |
| 50 | 50 | function shortcodely_get_sidebar_id( $name ) { |
| 51 | - /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. |
|
| 51 | + /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. |
|
| 52 | 52 | take the first one that matches */ |
| 53 | - global $wp_registered_sidebars; |
|
| 53 | + global $wp_registered_sidebars; |
|
| 54 | 54 | |
| 55 | - foreach ( $wp_registered_sidebars as $i => $a ) { |
|
| 56 | - if ( (isset( $a['name'] )) and ($a['name'] === $name) ) { |
|
| 57 | - return $i; |
|
| 58 | - } |
|
| 59 | - } |
|
| 55 | + foreach ( $wp_registered_sidebars as $i => $a ) { |
|
| 56 | + if ( (isset( $a['name'] )) and ($a['name'] === $name) ) { |
|
| 57 | + return $i; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - return false; |
|
| 61 | + return false; |
|
| 62 | 62 | } |
| 63 | 63 | /*-----------------------------------*/ |
| 64 | 64 | function shortcodely_get_sidebar_name( $id ) { |
| 65 | - /* dont need anymore ? or at least temporarily */ |
|
| 66 | - /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */ |
|
| 67 | - global $wp_registered_sidebars; |
|
| 68 | - foreach ( $wp_registered_sidebars as $i => $a ) { |
|
| 69 | - if ( (isset( $a['id'] )) and ($a['id'] === $id) ) { |
|
| 70 | - if ( isset( $a['name'] ) ) { |
|
| 71 | - return $a['name']; |
|
| 72 | - } else { |
|
| 73 | - return $id; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - return false; |
|
| 65 | + /* dont need anymore ? or at least temporarily */ |
|
| 66 | + /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */ |
|
| 67 | + global $wp_registered_sidebars; |
|
| 68 | + foreach ( $wp_registered_sidebars as $i => $a ) { |
|
| 69 | + if ( (isset( $a['id'] )) and ($a['id'] === $id) ) { |
|
| 70 | + if ( isset( $a['name'] ) ) { |
|
| 71 | + return $a['name']; |
|
| 72 | + } else { |
|
| 73 | + return $id; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + return false; |
|
| 79 | 79 | } |
| 80 | 80 | /*-----------------------------------*/ |
| 81 | 81 | function shortcodely_check_if_widget_debug() { |
| 82 | - global $said; |
|
| 83 | - // only do these debug if we are logged in and are the administrator |
|
| 84 | - |
|
| 85 | - if ( is_admin() ) { |
|
| 86 | - return false; |
|
| 87 | - } // if running in backend, then do not do debug. 20151217 |
|
| 88 | - |
|
| 89 | - if ( ( ! is_user_logged_in()) or ( ! current_user_can( 'administrator' )) ) { |
|
| 90 | - return false; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if ( isset( $_REQUEST['do_widget_debug'] ) ) { |
|
| 94 | - if ( empty( $said ) ) { |
|
| 95 | - $said = true; |
|
| 96 | - } else { |
|
| 97 | - return true; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $url_without_debug_query = esc_url( remove_query_arg( 'do_widget_debug' ) ); |
|
| 101 | - $eek = '<a href="' . $url_without_debug_query . '">Remove debug</a>'; |
|
| 102 | - echo '<br/>Note: Debug help is only shown to a logged-in Administrator.' |
|
| 103 | - . $eek |
|
| 104 | - . '<br />'; |
|
| 105 | - $text = shortcodely_show_shortcode_widget_possibilities(); |
|
| 106 | - echo $text; |
|
| 107 | - |
|
| 108 | - return true; |
|
| 109 | - } else { |
|
| 110 | - return false; |
|
| 111 | - } |
|
| 82 | + global $said; |
|
| 83 | + // only do these debug if we are logged in and are the administrator |
|
| 84 | + |
|
| 85 | + if ( is_admin() ) { |
|
| 86 | + return false; |
|
| 87 | + } // if running in backend, then do not do debug. 20151217 |
|
| 88 | + |
|
| 89 | + if ( ( ! is_user_logged_in()) or ( ! current_user_can( 'administrator' )) ) { |
|
| 90 | + return false; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if ( isset( $_REQUEST['do_widget_debug'] ) ) { |
|
| 94 | + if ( empty( $said ) ) { |
|
| 95 | + $said = true; |
|
| 96 | + } else { |
|
| 97 | + return true; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $url_without_debug_query = esc_url( remove_query_arg( 'do_widget_debug' ) ); |
|
| 101 | + $eek = '<a href="' . $url_without_debug_query . '">Remove debug</a>'; |
|
| 102 | + echo '<br/>Note: Debug help is only shown to a logged-in Administrator.' |
|
| 103 | + . $eek |
|
| 104 | + . '<br />'; |
|
| 105 | + $text = shortcodely_show_shortcode_widget_possibilities(); |
|
| 106 | + echo $text; |
|
| 107 | + |
|
| 108 | + return true; |
|
| 109 | + } else { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | 113 | /*-----------------------------------*/ |
| 114 | 114 | /** |
| 115 | 115 | * @param string $type |
| 116 | 116 | */ |
| 117 | 117 | function shortcodely_show_widget_debug( $type, $name, $id, $sidebar ) { |
| 118 | - global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount; |
|
| 119 | - // only do these debug if we are logged in and are the administrator |
|
| 120 | - |
|
| 121 | - $debug = shortcodely_check_if_widget_debug(); |
|
| 122 | - $text = shortcodely_show_shortcode_widget_possibilities(); |
|
| 123 | - |
|
| 124 | - if ( 'empty' == $type ) { |
|
| 125 | - if ( current_user_can( 'administrator' ) ) { |
|
| 126 | - $text = '<p>Problem with do_widget shortcode? Try one of the following:</p>' . $text; |
|
| 127 | - } |
|
| 128 | - } elseif ( ('which one' == $type) and ($debug) ) { |
|
| 129 | - $text = '<p>Debug help is on: Is your widget in the widgets_for_shortcodes sidebar?</p>' |
|
| 130 | - . $text; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - return $text; |
|
| 118 | + global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount; |
|
| 119 | + // only do these debug if we are logged in and are the administrator |
|
| 120 | + |
|
| 121 | + $debug = shortcodely_check_if_widget_debug(); |
|
| 122 | + $text = shortcodely_show_shortcode_widget_possibilities(); |
|
| 123 | + |
|
| 124 | + if ( 'empty' == $type ) { |
|
| 125 | + if ( current_user_can( 'administrator' ) ) { |
|
| 126 | + $text = '<p>Problem with do_widget shortcode? Try one of the following:</p>' . $text; |
|
| 127 | + } |
|
| 128 | + } elseif ( ('which one' == $type) and ($debug) ) { |
|
| 129 | + $text = '<p>Debug help is on: Is your widget in the widgets_for_shortcodes sidebar?</p>' |
|
| 130 | + . $text; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + return $text; |
|
| 134 | 134 | } |
| 135 | 135 | /*-----------------------------------*/ |
| 136 | 136 | function shortcodely_save_shortcodes_sidebar() { |
| 137 | - // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten |
|
| 138 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 139 | - if ( ! empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { |
|
| 140 | - update_option( 'sidebars_widgets_for_shortcodes_saved', $sidebars_widgets['widgets_for_shortcodes'] ); |
|
| 141 | - } else { // our shortcodes sidebar is empty but when to fix ? |
|
| 142 | - } |
|
| 137 | + // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten |
|
| 138 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 139 | + if ( ! empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { |
|
| 140 | + update_option( 'sidebars_widgets_for_shortcodes_saved', $sidebars_widgets['widgets_for_shortcodes'] ); |
|
| 141 | + } else { // our shortcodes sidebar is empty but when to fix ? |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | /*-----------------------------------*/ |
| 145 | 145 | function shortcodely_restore_shortcodes_sidebar() { |
| 146 | - // when switching a theme, restore the widgets we use for the shortcodes as they are getting overwritten |
|
| 147 | - global $_wp_sidebars_widgets; |
|
| 148 | - |
|
| 149 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 150 | - if ( empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { |
|
| 151 | - $sidebars_widgets['widgets_for_shortcodes'] = get_option( 'sidebars_widgets_for_shortcodes_saved' ); |
|
| 152 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 153 | - } |
|
| 146 | + // when switching a theme, restore the widgets we use for the shortcodes as they are getting overwritten |
|
| 147 | + global $_wp_sidebars_widgets; |
|
| 148 | + |
|
| 149 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 150 | + if ( empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { |
|
| 151 | + $sidebars_widgets['widgets_for_shortcodes'] = get_option( 'sidebars_widgets_for_shortcodes_saved' ); |
|
| 152 | + update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 153 | + } |
|
| 154 | 154 | } |
| 155 | 155 | /*-----------------------------------*/ |
| 156 | 156 | function shortcodely_upgrade_sidebar() { |
| 157 | - // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.? |
|
| 158 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 159 | - if ( ! empty( $sidebars_widgets['Shortcodes'] ) and empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { // we need to upgrade |
|
| 160 | - $sidebars_widgets['widgets_for_shortcodes'] = $sidebars_widgets['Shortcodes']; |
|
| 161 | - unset( $sidebars_widgets['Shortcodes'] ); |
|
| 162 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 163 | - add_action( 'admin_notices', 'widgets_shortcode_admin_notice' ); |
|
| 164 | - } |
|
| 157 | + // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.? |
|
| 158 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 159 | + if ( ! empty( $sidebars_widgets['Shortcodes'] ) and empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { // we need to upgrade |
|
| 160 | + $sidebars_widgets['widgets_for_shortcodes'] = $sidebars_widgets['Shortcodes']; |
|
| 161 | + unset( $sidebars_widgets['Shortcodes'] ); |
|
| 162 | + update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 163 | + add_action( 'admin_notices', 'widgets_shortcode_admin_notice' ); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function widgets_shortcode_admin_notice() { |
| 168 | - ?> |
|
| 168 | + ?> |
|
| 169 | 169 | <div class="updated"> |
| 170 | 170 | <p>Please go to widgets page and check your "widgets for shortcodes" sidebar. It will hopefully have been corrected upgraded with your widgets and all should be fine.</p> |
| 171 | 171 | </div> |
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | global $_wp_sidebars_widgets; |
| 11 | 11 | |
| 12 | 12 | $sidebars_widgets = $_wp_sidebars_widgets; |
| 13 | - ksort( $sidebars_widgets ); // push inactive down the bottom of the list |
|
| 13 | + ksort($sidebars_widgets); // push inactive down the bottom of the list |
|
| 14 | 14 | $text = '<ul>'; |
| 15 | - foreach ( $sidebars_widgets as $sidebarid => $sidebar ) { |
|
| 16 | - if ( is_array( $sidebar ) ) { |
|
| 15 | + foreach ($sidebars_widgets as $sidebarid => $sidebar) { |
|
| 16 | + if (is_array($sidebar)) { |
|
| 17 | 17 | $text .= '<li><em>[do_widget_area ' . $sidebarid . ']</em><ul>'; |
| 18 | - foreach ( $sidebar as $i => $w ) { |
|
| 18 | + foreach ($sidebar as $i => $w) { |
|
| 19 | 19 | $text .= '<li>'; |
| 20 | 20 | $text .= '[do_widget id="' . $w . '"]'; |
| 21 | 21 | $text .= '</li>'; |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /*-----------------------------------*/ |
| 32 | -function shortcodely_get_widgets_sidebar( $wid ) { |
|
| 32 | +function shortcodely_get_widgets_sidebar($wid) { |
|
| 33 | 33 | /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. |
| 34 | 34 | take the first one that matches */ |
| 35 | 35 | global $_wp_sidebars_widgets; |
| 36 | 36 | |
| 37 | - foreach ( $_wp_sidebars_widgets as $sidebarid => $sidebar ) { |
|
| 38 | - if ( is_array( $sidebar ) ) { // ignore the 'array version' sidebarid that isnt actually a sidebar |
|
| 39 | - foreach ( $sidebar as $i => $w ) { |
|
| 40 | - if ( $w == $wid ) { |
|
| 37 | + foreach ($_wp_sidebars_widgets as $sidebarid => $sidebar) { |
|
| 38 | + if (is_array($sidebar)) { // ignore the 'array version' sidebarid that isnt actually a sidebar |
|
| 39 | + foreach ($sidebar as $i => $w) { |
|
| 40 | + if ($w == $wid) { |
|
| 41 | 41 | return $sidebarid; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | return false; // widget id not in any sidebar |
| 48 | 48 | } |
| 49 | 49 | /*-----------------------------------*/ |
| 50 | -function shortcodely_get_sidebar_id( $name ) { |
|
| 50 | +function shortcodely_get_sidebar_id($name) { |
|
| 51 | 51 | /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. |
| 52 | 52 | take the first one that matches */ |
| 53 | 53 | global $wp_registered_sidebars; |
| 54 | 54 | |
| 55 | - foreach ( $wp_registered_sidebars as $i => $a ) { |
|
| 56 | - if ( (isset( $a['name'] )) and ($a['name'] === $name) ) { |
|
| 55 | + foreach ($wp_registered_sidebars as $i => $a) { |
|
| 56 | + if ((isset($a['name'])) and ($a['name'] === $name)) { |
|
| 57 | 57 | return $i; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | /*-----------------------------------*/ |
| 64 | -function shortcodely_get_sidebar_name( $id ) { |
|
| 64 | +function shortcodely_get_sidebar_name($id) { |
|
| 65 | 65 | /* dont need anymore ? or at least temporarily */ |
| 66 | 66 | /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */ |
| 67 | 67 | global $wp_registered_sidebars; |
| 68 | - foreach ( $wp_registered_sidebars as $i => $a ) { |
|
| 69 | - if ( (isset( $a['id'] )) and ($a['id'] === $id) ) { |
|
| 70 | - if ( isset( $a['name'] ) ) { |
|
| 68 | + foreach ($wp_registered_sidebars as $i => $a) { |
|
| 69 | + if ((isset($a['id'])) and ($a['id'] === $id)) { |
|
| 70 | + if (isset($a['name'])) { |
|
| 71 | 71 | return $a['name']; |
| 72 | 72 | } else { |
| 73 | 73 | return $id; |
@@ -82,22 +82,22 @@ discard block |
||
| 82 | 82 | global $said; |
| 83 | 83 | // only do these debug if we are logged in and are the administrator |
| 84 | 84 | |
| 85 | - if ( is_admin() ) { |
|
| 85 | + if (is_admin()) { |
|
| 86 | 86 | return false; |
| 87 | 87 | } // if running in backend, then do not do debug. 20151217 |
| 88 | 88 | |
| 89 | - if ( ( ! is_user_logged_in()) or ( ! current_user_can( 'administrator' )) ) { |
|
| 89 | + if (( ! is_user_logged_in()) or ( ! current_user_can('administrator'))) { |
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ( isset( $_REQUEST['do_widget_debug'] ) ) { |
|
| 94 | - if ( empty( $said ) ) { |
|
| 93 | + if (isset($_REQUEST['do_widget_debug'])) { |
|
| 94 | + if (empty($said)) { |
|
| 95 | 95 | $said = true; |
| 96 | 96 | } else { |
| 97 | 97 | return true; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $url_without_debug_query = esc_url( remove_query_arg( 'do_widget_debug' ) ); |
|
| 100 | + $url_without_debug_query = esc_url(remove_query_arg('do_widget_debug')); |
|
| 101 | 101 | $eek = '<a href="' . $url_without_debug_query . '">Remove debug</a>'; |
| 102 | 102 | echo '<br/>Note: Debug help is only shown to a logged-in Administrator.' |
| 103 | 103 | . $eek |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | /** |
| 115 | 115 | * @param string $type |
| 116 | 116 | */ |
| 117 | -function shortcodely_show_widget_debug( $type, $name, $id, $sidebar ) { |
|
| 117 | +function shortcodely_show_widget_debug($type, $name, $id, $sidebar) { |
|
| 118 | 118 | global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount; |
| 119 | 119 | // only do these debug if we are logged in and are the administrator |
| 120 | 120 | |
| 121 | 121 | $debug = shortcodely_check_if_widget_debug(); |
| 122 | 122 | $text = shortcodely_show_shortcode_widget_possibilities(); |
| 123 | 123 | |
| 124 | - if ( 'empty' == $type ) { |
|
| 125 | - if ( current_user_can( 'administrator' ) ) { |
|
| 124 | + if ('empty' == $type) { |
|
| 125 | + if (current_user_can('administrator')) { |
|
| 126 | 126 | $text = '<p>Problem with do_widget shortcode? Try one of the following:</p>' . $text; |
| 127 | 127 | } |
| 128 | - } elseif ( ('which one' == $type) and ($debug) ) { |
|
| 128 | + } elseif (('which one' == $type) and ($debug)) { |
|
| 129 | 129 | $text = '<p>Debug help is on: Is your widget in the widgets_for_shortcodes sidebar?</p>' |
| 130 | 130 | . $text; |
| 131 | 131 | } |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | function shortcodely_save_shortcodes_sidebar() { |
| 137 | 137 | // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten |
| 138 | 138 | $sidebars_widgets = wp_get_sidebars_widgets(); |
| 139 | - if ( ! empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { |
|
| 140 | - update_option( 'sidebars_widgets_for_shortcodes_saved', $sidebars_widgets['widgets_for_shortcodes'] ); |
|
| 139 | + if ( ! empty($sidebars_widgets['widgets_for_shortcodes'])) { |
|
| 140 | + update_option('sidebars_widgets_for_shortcodes_saved', $sidebars_widgets['widgets_for_shortcodes']); |
|
| 141 | 141 | } else { // our shortcodes sidebar is empty but when to fix ? |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | global $_wp_sidebars_widgets; |
| 148 | 148 | |
| 149 | 149 | $sidebars_widgets = wp_get_sidebars_widgets(); |
| 150 | - if ( empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { |
|
| 151 | - $sidebars_widgets['widgets_for_shortcodes'] = get_option( 'sidebars_widgets_for_shortcodes_saved' ); |
|
| 152 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 150 | + if (empty($sidebars_widgets['widgets_for_shortcodes'])) { |
|
| 151 | + $sidebars_widgets['widgets_for_shortcodes'] = get_option('sidebars_widgets_for_shortcodes_saved'); |
|
| 152 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | /*-----------------------------------*/ |
| 156 | 156 | function shortcodely_upgrade_sidebar() { |
| 157 | 157 | // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.? |
| 158 | 158 | $sidebars_widgets = wp_get_sidebars_widgets(); |
| 159 | - if ( ! empty( $sidebars_widgets['Shortcodes'] ) and empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) { // we need to upgrade |
|
| 159 | + if ( ! empty($sidebars_widgets['Shortcodes']) and empty($sidebars_widgets['widgets_for_shortcodes'])) { // we need to upgrade |
|
| 160 | 160 | $sidebars_widgets['widgets_for_shortcodes'] = $sidebars_widgets['Shortcodes']; |
| 161 | - unset( $sidebars_widgets['Shortcodes'] ); |
|
| 162 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 163 | - add_action( 'admin_notices', 'widgets_shortcode_admin_notice' ); |
|
| 161 | + unset($sidebars_widgets['Shortcodes']); |
|
| 162 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
| 163 | + add_action('admin_notices', 'widgets_shortcode_admin_notice'); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // ------------------------------------------------------------------------------------------------------------------ |
| 10 | -if ( ! class_exists( 'Shortcodely_Saw_Plugin_Admin' ) ) { |
|
| 10 | +if ( ! class_exists('Shortcodely_Saw_Plugin_Admin')) { |
|
| 11 | 11 | /* |
| 12 | 12 | * Shortcodely_Saw_Plugin_Admin Class Doc Comment |
| 13 | 13 | * |
@@ -43,26 +43,26 @@ discard block |
||
| 43 | 43 | public $parent_slug = 'plugin_listings_menu'; |
| 44 | 44 | public $accesslvl = 'manage_options'; |
| 45 | 45 | public function __construct() { |
| 46 | - add_action( 'admin_menu', array( &$this, 'register_settings_page' ) ); |
|
| 47 | - add_filter( 'plugin_action_links', array( &$this, 'add_action_link' ), 10, 2 ); |
|
| 46 | + add_action('admin_menu', array(&$this, 'register_settings_page')); |
|
| 47 | + add_filter('plugin_action_links', array(&$this, 'add_action_link'), 10, 2); |
|
| 48 | 48 | } |
| 49 | 49 | public function register_settings_page() { |
| 50 | - add_options_page( $this->longname, $this->shortname, $this->accesslvl, $this->hook, array( &$this, 'config_page' ) ); |
|
| 50 | + add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this, 'config_page')); |
|
| 51 | 51 | } |
| 52 | 52 | public function plugin_options_url() { |
| 53 | - return admin_url( 'options-general.php?page=' . $this->hook ); |
|
| 53 | + return admin_url('options-general.php?page=' . $this->hook); |
|
| 54 | 54 | } |
| 55 | 55 | /** |
| 56 | 56 | * Add a link to the settings page to the plugins list |
| 57 | 57 | */ |
| 58 | - public function add_action_link( $links, $file ) { |
|
| 58 | + public function add_action_link($links, $file) { |
|
| 59 | 59 | static $this_plugin; |
| 60 | - if ( empty( $this_plugin ) ) { |
|
| 60 | + if (empty($this_plugin)) { |
|
| 61 | 61 | $this_plugin = $this->filename; |
| 62 | 62 | } |
| 63 | - if ( $file == $this_plugin ) { |
|
| 64 | - $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __( 'Settings', 'shortcodely-shortcode-any-widget' ) . '</a>'; |
|
| 65 | - array_unshift( $links, $settings_link ); |
|
| 63 | + if ($file == $this_plugin) { |
|
| 64 | + $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings', 'shortcodely-shortcode-any-widget') . '</a>'; |
|
| 65 | + array_unshift($links, $settings_link); |
|
| 66 | 66 | } |
| 67 | 67 | return $links; |
| 68 | 68 | } |
@@ -70,51 +70,51 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * @param string $title |
| 72 | 72 | */ |
| 73 | - public function admin_heading( $title ) { |
|
| 73 | + public function admin_heading($title) { |
|
| 74 | 74 | echo '<div class="wrap" > |
| 75 | 75 | <div id="icon-options-general" class="icon32"><br /> |
| 76 | 76 | </div> |
| 77 | 77 | <h2>' . $title . ' </h2>'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function admin_subheading( $title ) { |
|
| 80 | + public function admin_subheading($title) { |
|
| 81 | 81 | echo '<h2>' . $title . '</h2>'; |
| 82 | 82 | } |
| 83 | 83 | public function config_page() { |
| 84 | - $this->admin_heading( $this->longname ); |
|
| 84 | + $this->admin_heading($this->longname); |
|
| 85 | 85 | echo '<h3>More detailed instructions at the wordpress plugin <a target="_new" href="http://wordpress.org/plugins/shortcodely/installation">installation and faq pages.</a></h3>'; |
| 86 | 86 | echo '<ol>'; |
| 87 | 87 | echo '<li>'; |
| 88 | - _e( 'Test your widget in a normal sidebar first.', 'shortcodely-shortcode-any-widget' ); |
|
| 89 | - echo ' <a title="Go to widget area" href="' . get_admin_url( '', 'widgets.php' ) . '">'; |
|
| 90 | - _e( 'Go to widgets', 'shortcodely-shortcode-any-widget' ); |
|
| 88 | + _e('Test your widget in a normal sidebar first.', 'shortcodely-shortcode-any-widget'); |
|
| 89 | + echo ' <a title="Go to widget area" href="' . get_admin_url('', 'widgets.php') . '">'; |
|
| 90 | + _e('Go to widgets', 'shortcodely-shortcode-any-widget'); |
|
| 91 | 91 | echo '</a>'; |
| 92 | 92 | echo '<li>'; |
| 93 | - _e( 'Drag the widgets you want to use to the shortcodes sidebar.', 'shortcodely-shortcode-any-widget' ); |
|
| 93 | + _e('Drag the widgets you want to use to the shortcodes sidebar.', 'shortcodely-shortcode-any-widget'); |
|
| 94 | 94 | echo '</li>'; |
| 95 | 95 | echo '<li>'; |
| 96 | - _e( 'Add a do_widget or do_widget_area shortcode to a page.', 'shortcodely-shortcode-any-widget' ); |
|
| 96 | + _e('Add a do_widget or do_widget_area shortcode to a page.', 'shortcodely-shortcode-any-widget'); |
|
| 97 | 97 | echo ' <a title="Create a page" href="' |
| 98 | - . get_admin_url( '', 'post-new.php?post_type=page&content=[do_widget Archives ]' ) |
|
| 98 | + . get_admin_url('', 'post-new.php?post_type=page&content=[do_widget Archives ]') |
|
| 99 | 99 | . '">'; |
| 100 | - _e( 'Create a page with example do_widget shortcode', 'shortcodely-shortcode-any-widget' ); |
|
| 100 | + _e('Create a page with example do_widget shortcode', 'shortcodely-shortcode-any-widget'); |
|
| 101 | 101 | echo '</a>'; |
| 102 | 102 | echo '</li>'; |
| 103 | 103 | echo '</ol>'; |
| 104 | 104 | |
| 105 | 105 | echo '<h2>'; |
| 106 | - _e( 'To add a single widget to a page', 'shortcodely-shortcode-any-widget' ); |
|
| 106 | + _e('To add a single widget to a page', 'shortcodely-shortcode-any-widget'); |
|
| 107 | 107 | echo '</h2>'; |
| 108 | 108 | echo '<ul>'; |
| 109 | 109 | echo '<li>'; |
| 110 | - _e( 'Add the shortcode [do_widget widgetname] to a page:', 'shortcodely-shortcode-any-widget' ); |
|
| 110 | + _e('Add the shortcode [do_widget widgetname] to a page:', 'shortcodely-shortcode-any-widget'); |
|
| 111 | 111 | echo '</li>'; |
| 112 | 112 | echo '<li>'; |
| 113 | 113 | echo '<li>'; |
| 114 | 114 | echo '[do_widget categories] or [do_widget name=categories] '; |
| 115 | 115 | echo '</li>'; |
| 116 | 116 | echo '<li>'; |
| 117 | - _e( '[do_widget "tag cloud"] or [do_widget id=widgetid]', 'shortcodely-shortcode-any-widget' ); |
|
| 117 | + _e('[do_widget "tag cloud"] or [do_widget id=widgetid]', 'shortcodely-shortcode-any-widget'); |
|
| 118 | 118 | echo '</li>'; |
| 119 | 119 | echo '<li>'; |
| 120 | 120 | echo 'To see a list of your widgets in their sidebars, add <b>?do_widget_debug</b> to the url of page with the do_widget shortcode.'; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | echo '<br />'; |
| 125 | 125 | echo '<h2>'; |
| 126 | - _e( 'More advanced options:', 'shortcodely-shortcode-any-widget' ); |
|
| 126 | + _e('More advanced options:', 'shortcodely-shortcode-any-widget'); |
|
| 127 | 127 | echo '</h2>'; |
| 128 | 128 | echo '<ul><li>'; |
| 129 | 129 | echo 'Use title=false to hide a widget title. '; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | echo '[do_widget pages title=false] will hide the widget title'; |
| 133 | 133 | echo '</li></ul>'; |
| 134 | 134 | echo '<h3>'; |
| 135 | - _e( 'To change the style, change the html:', 'shortcodely-shortcode-any-widget' ); |
|
| 135 | + _e('To change the style, change the html:', 'shortcodely-shortcode-any-widget'); |
|
| 136 | 136 | echo '</h3>'; |
| 137 | 137 | echo '<ul>'; |
| 138 | 138 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | echo '</ul>'; |
| 173 | 173 | |
| 174 | 174 | echo '<h2>'; |
| 175 | - _e( 'To add multiple instances of the same widget:', 'shortcodely-shortcode-any-widget' ); |
|
| 175 | + _e('To add multiple instances of the same widget:', 'shortcodely-shortcode-any-widget'); |
|
| 176 | 176 | |
| 177 | 177 | echo '</h2>'; |
| 178 | 178 | echo '<ul>'; |
@@ -182,15 +182,15 @@ discard block |
||
| 182 | 182 | echo '</ul>'; |
| 183 | 183 | |
| 184 | 184 | echo '<h2>'; |
| 185 | - _e( 'To add a widget area - all widgets in the widget area:', 'shortcodely-shortcode-any-widget' ); |
|
| 185 | + _e('To add a widget area - all widgets in the widget area:', 'shortcodely-shortcode-any-widget'); |
|
| 186 | 186 | |
| 187 | 187 | echo '</h2>'; |
| 188 | 188 | echo '<ul>'; |
| 189 | 189 | echo '<li>'; |
| 190 | 190 | echo '<a title="Create a page" href="' |
| 191 | - . get_admin_url( '', 'post-new.php?post_type=page&content=[do_widget_area]' ) |
|
| 191 | + . get_admin_url('', 'post-new.php?post_type=page&content=[do_widget_area]') |
|
| 192 | 192 | . '"> '; |
| 193 | - _e( 'Create a page with do_widget_area shortcode', 'shortcodely-shortcode-any-widget' ); |
|
| 193 | + _e('Create a page with do_widget_area shortcode', 'shortcodely-shortcode-any-widget'); |
|
| 194 | 194 | echo '</a> Hoping to use theme styling.'; |
| 195 | 195 | echo '</li>'; |
| 196 | 196 | echo '<li>'; |
@@ -200,17 +200,17 @@ discard block |
||
| 200 | 200 | 'post-new.php?post_type=page&content=[do_widget_area widget_area_class=none]' |
| 201 | 201 | ) |
| 202 | 202 | . '"> '; |
| 203 | - _e( 'Create a page with do_widget_area shortcode without the widget_area class', 'shortcodely-shortcode-any-widget' ); |
|
| 203 | + _e('Create a page with do_widget_area shortcode without the widget_area class', 'shortcodely-shortcode-any-widget'); |
|
| 204 | 204 | echo '</a> Hoping to avoid theme sidebar styling.'; |
| 205 | 205 | echo '</li>'; |
| 206 | 206 | echo '<li>'; |
| 207 | - _e( 'Examples:', 'shortcodely-shortcode-any-widget' ); |
|
| 207 | + _e('Examples:', 'shortcodely-shortcode-any-widget'); |
|
| 208 | 208 | echo '</li>'; |
| 209 | 209 | echo '<li>'; |
| 210 | - _e( '[do_widget_area] or [do_widget_area widget_area=sidebar-1]', 'shortcodely-shortcode-any-widget' ); |
|
| 210 | + _e('[do_widget_area] or [do_widget_area widget_area=sidebar-1]', 'shortcodely-shortcode-any-widget'); |
|
| 211 | 211 | echo '</li>'; |
| 212 | 212 | echo '<li>'; |
| 213 | - _e( 'NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.', 'shortcodely-shortcode-any-widget' ); |
|
| 213 | + _e('NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.', 'shortcodely-shortcode-any-widget'); |
|
| 214 | 214 | echo '</li>'; |
| 215 | 215 | echo '</ul>'; |
| 216 | 216 | echo '<br />'; |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | * Info box with link to the support forums. |
| 222 | 222 | */ |
| 223 | 223 | public function plugin_support() { |
| 224 | - $content = '<p>' . __( 'If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the', 'shortcodely-shortcode-any-widget' ) . ' <a href="http://wordpress.org/tags/' . $this->hook . '">' . __( 'Support forums', 'shortcodely-shortcode-any-widget' ) . '</a>.</p>'; |
|
| 225 | - $this->postbox( $this->hook . 'support', 'Need support?', $content ); |
|
| 224 | + $content = '<p>' . __('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the', 'shortcodely-shortcode-any-widget') . ' <a href="http://wordpress.org/tags/' . $this->hook . '">' . __('Support forums', 'shortcodely-shortcode-any-widget') . '</a>.</p>'; |
|
| 225 | + $this->postbox($this->hook . 'support', 'Need support?', $content); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public function text_limit( $text, $limit, $finish = ' […]' ) { |
|
| 229 | - if ( strlen( $text ) > $limit ) { |
|
| 230 | - $text = substr( $text, 0, $limit ); |
|
| 231 | - $text = substr( $text, 0, - (strlen( strrchr( $text, ' ' ) )) ); |
|
| 228 | + public function text_limit($text, $limit, $finish = ' […]') { |
|
| 229 | + if (strlen($text) > $limit) { |
|
| 230 | + $text = substr($text, 0, $limit); |
|
| 231 | + $text = substr($text, 0, - (strlen(strrchr($text, ' ')))); |
|
| 232 | 232 | $text .= $finish; |
| 233 | 233 | } |
| 234 | 234 | return $text; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | // ------------------------------------------------------------------------------------------------------------------ |
| 10 | 10 | if ( ! class_exists( 'Shortcodely_Saw_Plugin_Admin' ) ) { |
| 11 | - /* |
|
| 11 | + /* |
|
| 12 | 12 | * Shortcodely_Saw_Plugin_Admin Class Doc Comment |
| 13 | 13 | * |
| 14 | 14 | * @ category Class |
@@ -18,221 +18,221 @@ discard block |
||
| 18 | 18 | * @ link http://www.github.com/patilswapnilv/shortcodely |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | - class Shortcodely_Saw_Plugin_Admin { |
|
| 21 | + class Shortcodely_Saw_Plugin_Admin { |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | |
| 25 | - public $hook = 'shortcodely_saw'; |
|
| 26 | - public $filename = 'shortcodely_shortcode_any_widget/shortcodely_shortcode_any_widget.php'; |
|
| 27 | - public $longname = 'Shortcode any widget - insert widgets or widget areas into a page.'; |
|
| 28 | - public $shortname = 'Shortcode any widget'; |
|
| 29 | - public $optionname = ''; |
|
| 30 | - /** |
|
| 31 | - * Homepage variable Doc Comment |
|
| 32 | - * |
|
| 33 | - * @category variable |
|
| 34 | - * @package shortcodely |
|
| 35 | - * @author patilswapnilv |
|
| 36 | - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
|
| 37 | - * @link http://www.github.com/patilswapnilv/shortcodely |
|
| 38 | - * / |
|
| 25 | + public $hook = 'shortcodely_saw'; |
|
| 26 | + public $filename = 'shortcodely_shortcode_any_widget/shortcodely_shortcode_any_widget.php'; |
|
| 27 | + public $longname = 'Shortcode any widget - insert widgets or widget areas into a page.'; |
|
| 28 | + public $shortname = 'Shortcode any widget'; |
|
| 29 | + public $optionname = ''; |
|
| 30 | + /** |
|
| 31 | + * Homepage variable Doc Comment |
|
| 32 | + * |
|
| 33 | + * @category variable |
|
| 34 | + * @package shortcodely |
|
| 35 | + * @author patilswapnilv |
|
| 36 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
|
| 37 | + * @link http://www.github.com/patilswapnilv/shortcodely |
|
| 38 | + * / |
|
| 39 | 39 | /** |
| 40 | - * This is a "Docblock Comment," also known as a "docblock." The class' |
|
| 41 | - * docblock, below, contains a complete description of how to write these. |
|
| 42 | - */ |
|
| 43 | - public $homepage = ''; |
|
| 44 | - public $parent_slug = 'plugin_listings_menu'; |
|
| 45 | - public $accesslvl = 'manage_options'; |
|
| 46 | - public function __construct() { |
|
| 47 | - add_action( 'admin_menu', array( &$this, 'register_settings_page' ) ); |
|
| 48 | - add_filter( 'plugin_action_links', array( &$this, 'add_action_link' ), 10, 2 ); |
|
| 49 | - } |
|
| 50 | - public function register_settings_page() { |
|
| 51 | - add_options_page( $this->longname, $this->shortname, $this->accesslvl, $this->hook, array( &$this, 'config_page' ) ); |
|
| 52 | - } |
|
| 53 | - public function plugin_options_url() { |
|
| 54 | - return admin_url( 'options-general.php?page=' . $this->hook ); |
|
| 55 | - } |
|
| 56 | - /** |
|
| 57 | - * Add a link to the settings page to the plugins list |
|
| 58 | - */ |
|
| 59 | - public function add_action_link( $links, $file ) { |
|
| 60 | - static $this_plugin; |
|
| 61 | - if ( empty( $this_plugin ) ) { |
|
| 62 | - $this_plugin = $this->filename; |
|
| 63 | - } |
|
| 64 | - if ( $file == $this_plugin ) { |
|
| 65 | - $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __( 'Settings', 'shortcodely-shortcode-any-widget' ) . '</a>'; |
|
| 66 | - array_unshift( $links, $settings_link ); |
|
| 67 | - } |
|
| 68 | - return $links; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param string $title |
|
| 73 | - */ |
|
| 74 | - public function admin_heading( $title ) { |
|
| 75 | - echo '<div class="wrap" > |
|
| 40 | + * This is a "Docblock Comment," also known as a "docblock." The class' |
|
| 41 | + * docblock, below, contains a complete description of how to write these. |
|
| 42 | + */ |
|
| 43 | + public $homepage = ''; |
|
| 44 | + public $parent_slug = 'plugin_listings_menu'; |
|
| 45 | + public $accesslvl = 'manage_options'; |
|
| 46 | + public function __construct() { |
|
| 47 | + add_action( 'admin_menu', array( &$this, 'register_settings_page' ) ); |
|
| 48 | + add_filter( 'plugin_action_links', array( &$this, 'add_action_link' ), 10, 2 ); |
|
| 49 | + } |
|
| 50 | + public function register_settings_page() { |
|
| 51 | + add_options_page( $this->longname, $this->shortname, $this->accesslvl, $this->hook, array( &$this, 'config_page' ) ); |
|
| 52 | + } |
|
| 53 | + public function plugin_options_url() { |
|
| 54 | + return admin_url( 'options-general.php?page=' . $this->hook ); |
|
| 55 | + } |
|
| 56 | + /** |
|
| 57 | + * Add a link to the settings page to the plugins list |
|
| 58 | + */ |
|
| 59 | + public function add_action_link( $links, $file ) { |
|
| 60 | + static $this_plugin; |
|
| 61 | + if ( empty( $this_plugin ) ) { |
|
| 62 | + $this_plugin = $this->filename; |
|
| 63 | + } |
|
| 64 | + if ( $file == $this_plugin ) { |
|
| 65 | + $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __( 'Settings', 'shortcodely-shortcode-any-widget' ) . '</a>'; |
|
| 66 | + array_unshift( $links, $settings_link ); |
|
| 67 | + } |
|
| 68 | + return $links; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param string $title |
|
| 73 | + */ |
|
| 74 | + public function admin_heading( $title ) { |
|
| 75 | + echo '<div class="wrap" > |
|
| 76 | 76 | <div id="icon-options-general" class="icon32"><br /> |
| 77 | 77 | </div> |
| 78 | 78 | <h2>' . $title . ' </h2>'; |
| 79 | - } |
|
| 80 | - |
|
| 81 | - public function admin_subheading( $title ) { |
|
| 82 | - echo '<h2>' . $title . '</h2>'; |
|
| 83 | - } |
|
| 84 | - public function config_page() { |
|
| 85 | - $this->admin_heading( $this->longname ); |
|
| 86 | - echo '<h3>More detailed instructions at the wordpress plugin <a target="_new" href="http://wordpress.org/plugins/shortcodely/installation">installation and faq pages.</a></h3>'; |
|
| 87 | - echo '<ol>'; |
|
| 88 | - echo '<li>'; |
|
| 89 | - _e( 'Test your widget in a normal sidebar first.', 'shortcodely-shortcode-any-widget' ); |
|
| 90 | - echo ' <a title="Go to widget area" href="' . get_admin_url( '', 'widgets.php' ) . '">'; |
|
| 91 | - _e( 'Go to widgets', 'shortcodely-shortcode-any-widget' ); |
|
| 92 | - echo '</a>'; |
|
| 93 | - echo '<li>'; |
|
| 94 | - _e( 'Drag the widgets you want to use to the shortcodes sidebar.', 'shortcodely-shortcode-any-widget' ); |
|
| 95 | - echo '</li>'; |
|
| 96 | - echo '<li>'; |
|
| 97 | - _e( 'Add a do_widget or do_widget_area shortcode to a page.', 'shortcodely-shortcode-any-widget' ); |
|
| 98 | - echo ' <a title="Create a page" href="' |
|
| 99 | - . get_admin_url( '', 'post-new.php?post_type=page&content=[do_widget Archives ]' ) |
|
| 100 | - . '">'; |
|
| 101 | - _e( 'Create a page with example do_widget shortcode', 'shortcodely-shortcode-any-widget' ); |
|
| 102 | - echo '</a>'; |
|
| 103 | - echo '</li>'; |
|
| 104 | - echo '</ol>'; |
|
| 105 | - |
|
| 106 | - echo '<h2>'; |
|
| 107 | - _e( 'To add a single widget to a page', 'shortcodely-shortcode-any-widget' ); |
|
| 108 | - echo '</h2>'; |
|
| 109 | - echo '<ul>'; |
|
| 110 | - echo '<li>'; |
|
| 111 | - _e( 'Add the shortcode [do_widget widgetname] to a page:', 'shortcodely-shortcode-any-widget' ); |
|
| 112 | - echo '</li>'; |
|
| 113 | - echo '<li>'; |
|
| 114 | - echo '<li>'; |
|
| 115 | - echo '[do_widget categories] or [do_widget name=categories] '; |
|
| 116 | - echo '</li>'; |
|
| 117 | - echo '<li>'; |
|
| 118 | - _e( '[do_widget "tag cloud"] or [do_widget id=widgetid]', 'shortcodely-shortcode-any-widget' ); |
|
| 119 | - echo '</li>'; |
|
| 120 | - echo '<li>'; |
|
| 121 | - echo 'To see a list of your widgets in their sidebars, add <b>?do_widget_debug</b> to the url of page with the do_widget shortcode.'; |
|
| 122 | - echo '</li>'; |
|
| 123 | - echo '</ul>'; |
|
| 124 | - |
|
| 125 | - echo '<br />'; |
|
| 126 | - echo '<h2>'; |
|
| 127 | - _e( 'More advanced options:', 'shortcodely-shortcode-any-widget' ); |
|
| 128 | - echo '</h2>'; |
|
| 129 | - echo '<ul><li>'; |
|
| 130 | - echo 'Use title=false to hide a widget title. '; |
|
| 131 | - echo '</li>'; |
|
| 132 | - echo '<li>'; |
|
| 133 | - echo '[do_widget pages title=false] will hide the widget title'; |
|
| 134 | - echo '</li></ul>'; |
|
| 135 | - echo '<h3>'; |
|
| 136 | - _e( 'To change the style, change the html:', 'shortcodely-shortcode-any-widget' ); |
|
| 137 | - echo '</h3>'; |
|
| 138 | - echo '<ul>'; |
|
| 139 | - |
|
| 140 | - echo '<li>'; |
|
| 141 | - echo 'Use title=somehtmltag and wrap=somehtmltag to change the html used. This may change how your theme\'s css affects the widget when it is in page. It all depends what what html selectors your theme uses.'; |
|
| 142 | - echo '</li>'; |
|
| 143 | - echo '<li>'; |
|
| 144 | - echo ' Use class=yourclassname to add a class - maybe to override your themes widget styling? Obviously you must have css that applies to that class.'; |
|
| 145 | - echo '</li>'; |
|
| 146 | - |
|
| 147 | - echo '<li>'; |
|
| 148 | - echo '[do_widget pages title=h3] give the title a heading 3 html tag.'; |
|
| 149 | - echo '</li>'; |
|
| 150 | - echo '<li>'; |
|
| 151 | - echo '[do_widget "tag cloud" wrap=aside] will wrap the widget in an "aside" html tag.'; |
|
| 152 | - echo '</li>'; |
|
| 153 | - |
|
| 154 | - echo '</ul>'; |
|
| 155 | - |
|
| 156 | - echo '<h4>'; |
|
| 157 | - echo 'Valid title html tags are : </h4><ul>'; |
|
| 158 | - echo '<li>h1</li>'; |
|
| 159 | - echo '<li>h2</li>'; |
|
| 160 | - echo '<li>h3</li>'; |
|
| 161 | - echo '<li>h4</li>'; |
|
| 162 | - echo '<li>h5</li>'; |
|
| 163 | - echo '<li>header</li>'; |
|
| 164 | - echo '<li>strong</li>'; |
|
| 165 | - echo '<li>em</li>'; |
|
| 166 | - echo '</ul>'; |
|
| 167 | - |
|
| 168 | - echo '<h4>Valid html wrap tags are :</h4><ul>'; |
|
| 169 | - echo '<li>div</li>'; |
|
| 170 | - echo '<li>p</li>'; |
|
| 171 | - echo '<li>aside</li>'; |
|
| 172 | - echo '<li>section</li>'; |
|
| 173 | - echo '</ul>'; |
|
| 174 | - |
|
| 175 | - echo '<h2>'; |
|
| 176 | - _e( 'To add multiple instances of the same widget:', 'shortcodely-shortcode-any-widget' ); |
|
| 177 | - |
|
| 178 | - echo '</h2>'; |
|
| 179 | - echo '<ul>'; |
|
| 180 | - echo '<li>'; |
|
| 181 | - echo '[do_widget id=widgetid1] [do_widget id=widgetid2]'; |
|
| 182 | - echo '</li>'; |
|
| 183 | - echo '</ul>'; |
|
| 184 | - |
|
| 185 | - echo '<h2>'; |
|
| 186 | - _e( 'To add a widget area - all widgets in the widget area:', 'shortcodely-shortcode-any-widget' ); |
|
| 187 | - |
|
| 188 | - echo '</h2>'; |
|
| 189 | - echo '<ul>'; |
|
| 190 | - echo '<li>'; |
|
| 191 | - echo '<a title="Create a page" href="' |
|
| 192 | - . get_admin_url( '', 'post-new.php?post_type=page&content=[do_widget_area]' ) |
|
| 193 | - . '"> '; |
|
| 194 | - _e( 'Create a page with do_widget_area shortcode', 'shortcodely-shortcode-any-widget' ); |
|
| 195 | - echo '</a> Hoping to use theme styling.'; |
|
| 196 | - echo '</li>'; |
|
| 197 | - echo '<li>'; |
|
| 198 | - echo '<a title="Create a page" href="' |
|
| 199 | - . get_admin_url( |
|
| 200 | - '', |
|
| 201 | - 'post-new.php?post_type=page&content=[do_widget_area widget_area_class=none]' |
|
| 202 | - ) |
|
| 203 | - . '"> '; |
|
| 204 | - _e( 'Create a page with do_widget_area shortcode without the widget_area class', 'shortcodely-shortcode-any-widget' ); |
|
| 205 | - echo '</a> Hoping to avoid theme sidebar styling.'; |
|
| 206 | - echo '</li>'; |
|
| 207 | - echo '<li>'; |
|
| 208 | - _e( 'Examples:', 'shortcodely-shortcode-any-widget' ); |
|
| 209 | - echo '</li>'; |
|
| 210 | - echo '<li>'; |
|
| 211 | - _e( '[do_widget_area] or [do_widget_area widget_area=sidebar-1]', 'shortcodely-shortcode-any-widget' ); |
|
| 212 | - echo '</li>'; |
|
| 213 | - echo '<li>'; |
|
| 214 | - _e( 'NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.', 'shortcodely-shortcode-any-widget' ); |
|
| 215 | - echo '</li>'; |
|
| 216 | - echo '</ul>'; |
|
| 217 | - echo '<br />'; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * Info box with link to the support forums. |
|
| 223 | - */ |
|
| 224 | - public function plugin_support() { |
|
| 225 | - $content = '<p>' . __( 'If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the', 'shortcodely-shortcode-any-widget' ) . ' <a href="http://wordpress.org/tags/' . $this->hook . '">' . __( 'Support forums', 'shortcodely-shortcode-any-widget' ) . '</a>.</p>'; |
|
| 226 | - $this->postbox( $this->hook . 'support', 'Need support?', $content ); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - public function text_limit( $text, $limit, $finish = ' […]' ) { |
|
| 230 | - if ( strlen( $text ) > $limit ) { |
|
| 231 | - $text = substr( $text, 0, $limit ); |
|
| 232 | - $text = substr( $text, 0, - (strlen( strrchr( $text, ' ' ) )) ); |
|
| 233 | - $text .= $finish; |
|
| 234 | - } |
|
| 235 | - return $text; |
|
| 236 | - } |
|
| 237 | - } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public function admin_subheading( $title ) { |
|
| 82 | + echo '<h2>' . $title . '</h2>'; |
|
| 83 | + } |
|
| 84 | + public function config_page() { |
|
| 85 | + $this->admin_heading( $this->longname ); |
|
| 86 | + echo '<h3>More detailed instructions at the wordpress plugin <a target="_new" href="http://wordpress.org/plugins/shortcodely/installation">installation and faq pages.</a></h3>'; |
|
| 87 | + echo '<ol>'; |
|
| 88 | + echo '<li>'; |
|
| 89 | + _e( 'Test your widget in a normal sidebar first.', 'shortcodely-shortcode-any-widget' ); |
|
| 90 | + echo ' <a title="Go to widget area" href="' . get_admin_url( '', 'widgets.php' ) . '">'; |
|
| 91 | + _e( 'Go to widgets', 'shortcodely-shortcode-any-widget' ); |
|
| 92 | + echo '</a>'; |
|
| 93 | + echo '<li>'; |
|
| 94 | + _e( 'Drag the widgets you want to use to the shortcodes sidebar.', 'shortcodely-shortcode-any-widget' ); |
|
| 95 | + echo '</li>'; |
|
| 96 | + echo '<li>'; |
|
| 97 | + _e( 'Add a do_widget or do_widget_area shortcode to a page.', 'shortcodely-shortcode-any-widget' ); |
|
| 98 | + echo ' <a title="Create a page" href="' |
|
| 99 | + . get_admin_url( '', 'post-new.php?post_type=page&content=[do_widget Archives ]' ) |
|
| 100 | + . '">'; |
|
| 101 | + _e( 'Create a page with example do_widget shortcode', 'shortcodely-shortcode-any-widget' ); |
|
| 102 | + echo '</a>'; |
|
| 103 | + echo '</li>'; |
|
| 104 | + echo '</ol>'; |
|
| 105 | + |
|
| 106 | + echo '<h2>'; |
|
| 107 | + _e( 'To add a single widget to a page', 'shortcodely-shortcode-any-widget' ); |
|
| 108 | + echo '</h2>'; |
|
| 109 | + echo '<ul>'; |
|
| 110 | + echo '<li>'; |
|
| 111 | + _e( 'Add the shortcode [do_widget widgetname] to a page:', 'shortcodely-shortcode-any-widget' ); |
|
| 112 | + echo '</li>'; |
|
| 113 | + echo '<li>'; |
|
| 114 | + echo '<li>'; |
|
| 115 | + echo '[do_widget categories] or [do_widget name=categories] '; |
|
| 116 | + echo '</li>'; |
|
| 117 | + echo '<li>'; |
|
| 118 | + _e( '[do_widget "tag cloud"] or [do_widget id=widgetid]', 'shortcodely-shortcode-any-widget' ); |
|
| 119 | + echo '</li>'; |
|
| 120 | + echo '<li>'; |
|
| 121 | + echo 'To see a list of your widgets in their sidebars, add <b>?do_widget_debug</b> to the url of page with the do_widget shortcode.'; |
|
| 122 | + echo '</li>'; |
|
| 123 | + echo '</ul>'; |
|
| 124 | + |
|
| 125 | + echo '<br />'; |
|
| 126 | + echo '<h2>'; |
|
| 127 | + _e( 'More advanced options:', 'shortcodely-shortcode-any-widget' ); |
|
| 128 | + echo '</h2>'; |
|
| 129 | + echo '<ul><li>'; |
|
| 130 | + echo 'Use title=false to hide a widget title. '; |
|
| 131 | + echo '</li>'; |
|
| 132 | + echo '<li>'; |
|
| 133 | + echo '[do_widget pages title=false] will hide the widget title'; |
|
| 134 | + echo '</li></ul>'; |
|
| 135 | + echo '<h3>'; |
|
| 136 | + _e( 'To change the style, change the html:', 'shortcodely-shortcode-any-widget' ); |
|
| 137 | + echo '</h3>'; |
|
| 138 | + echo '<ul>'; |
|
| 139 | + |
|
| 140 | + echo '<li>'; |
|
| 141 | + echo 'Use title=somehtmltag and wrap=somehtmltag to change the html used. This may change how your theme\'s css affects the widget when it is in page. It all depends what what html selectors your theme uses.'; |
|
| 142 | + echo '</li>'; |
|
| 143 | + echo '<li>'; |
|
| 144 | + echo ' Use class=yourclassname to add a class - maybe to override your themes widget styling? Obviously you must have css that applies to that class.'; |
|
| 145 | + echo '</li>'; |
|
| 146 | + |
|
| 147 | + echo '<li>'; |
|
| 148 | + echo '[do_widget pages title=h3] give the title a heading 3 html tag.'; |
|
| 149 | + echo '</li>'; |
|
| 150 | + echo '<li>'; |
|
| 151 | + echo '[do_widget "tag cloud" wrap=aside] will wrap the widget in an "aside" html tag.'; |
|
| 152 | + echo '</li>'; |
|
| 153 | + |
|
| 154 | + echo '</ul>'; |
|
| 155 | + |
|
| 156 | + echo '<h4>'; |
|
| 157 | + echo 'Valid title html tags are : </h4><ul>'; |
|
| 158 | + echo '<li>h1</li>'; |
|
| 159 | + echo '<li>h2</li>'; |
|
| 160 | + echo '<li>h3</li>'; |
|
| 161 | + echo '<li>h4</li>'; |
|
| 162 | + echo '<li>h5</li>'; |
|
| 163 | + echo '<li>header</li>'; |
|
| 164 | + echo '<li>strong</li>'; |
|
| 165 | + echo '<li>em</li>'; |
|
| 166 | + echo '</ul>'; |
|
| 167 | + |
|
| 168 | + echo '<h4>Valid html wrap tags are :</h4><ul>'; |
|
| 169 | + echo '<li>div</li>'; |
|
| 170 | + echo '<li>p</li>'; |
|
| 171 | + echo '<li>aside</li>'; |
|
| 172 | + echo '<li>section</li>'; |
|
| 173 | + echo '</ul>'; |
|
| 174 | + |
|
| 175 | + echo '<h2>'; |
|
| 176 | + _e( 'To add multiple instances of the same widget:', 'shortcodely-shortcode-any-widget' ); |
|
| 177 | + |
|
| 178 | + echo '</h2>'; |
|
| 179 | + echo '<ul>'; |
|
| 180 | + echo '<li>'; |
|
| 181 | + echo '[do_widget id=widgetid1] [do_widget id=widgetid2]'; |
|
| 182 | + echo '</li>'; |
|
| 183 | + echo '</ul>'; |
|
| 184 | + |
|
| 185 | + echo '<h2>'; |
|
| 186 | + _e( 'To add a widget area - all widgets in the widget area:', 'shortcodely-shortcode-any-widget' ); |
|
| 187 | + |
|
| 188 | + echo '</h2>'; |
|
| 189 | + echo '<ul>'; |
|
| 190 | + echo '<li>'; |
|
| 191 | + echo '<a title="Create a page" href="' |
|
| 192 | + . get_admin_url( '', 'post-new.php?post_type=page&content=[do_widget_area]' ) |
|
| 193 | + . '"> '; |
|
| 194 | + _e( 'Create a page with do_widget_area shortcode', 'shortcodely-shortcode-any-widget' ); |
|
| 195 | + echo '</a> Hoping to use theme styling.'; |
|
| 196 | + echo '</li>'; |
|
| 197 | + echo '<li>'; |
|
| 198 | + echo '<a title="Create a page" href="' |
|
| 199 | + . get_admin_url( |
|
| 200 | + '', |
|
| 201 | + 'post-new.php?post_type=page&content=[do_widget_area widget_area_class=none]' |
|
| 202 | + ) |
|
| 203 | + . '"> '; |
|
| 204 | + _e( 'Create a page with do_widget_area shortcode without the widget_area class', 'shortcodely-shortcode-any-widget' ); |
|
| 205 | + echo '</a> Hoping to avoid theme sidebar styling.'; |
|
| 206 | + echo '</li>'; |
|
| 207 | + echo '<li>'; |
|
| 208 | + _e( 'Examples:', 'shortcodely-shortcode-any-widget' ); |
|
| 209 | + echo '</li>'; |
|
| 210 | + echo '<li>'; |
|
| 211 | + _e( '[do_widget_area] or [do_widget_area widget_area=sidebar-1]', 'shortcodely-shortcode-any-widget' ); |
|
| 212 | + echo '</li>'; |
|
| 213 | + echo '<li>'; |
|
| 214 | + _e( 'NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.', 'shortcodely-shortcode-any-widget' ); |
|
| 215 | + echo '</li>'; |
|
| 216 | + echo '</ul>'; |
|
| 217 | + echo '<br />'; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * Info box with link to the support forums. |
|
| 223 | + */ |
|
| 224 | + public function plugin_support() { |
|
| 225 | + $content = '<p>' . __( 'If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the', 'shortcodely-shortcode-any-widget' ) . ' <a href="http://wordpress.org/tags/' . $this->hook . '">' . __( 'Support forums', 'shortcodely-shortcode-any-widget' ) . '</a>.</p>'; |
|
| 226 | + $this->postbox( $this->hook . 'support', 'Need support?', $content ); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + public function text_limit( $text, $limit, $finish = ' […]' ) { |
|
| 230 | + if ( strlen( $text ) > $limit ) { |
|
| 231 | + $text = substr( $text, 0, $limit ); |
|
| 232 | + $text = substr( $text, 0, - (strlen( strrchr( $text, ' ' ) )) ); |
|
| 233 | + $text .= $finish; |
|
| 234 | + } |
|
| 235 | + return $text; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
@@ -32,6 +32,9 @@ discard block |
||
| 32 | 32 | return true; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | +/** |
|
| 36 | + * @param integer $priority |
|
| 37 | + */ |
|
| 35 | 38 | function _test_filter_build_unique_id($tag, $function, $priority) { |
| 36 | 39 | if ( is_string($function) ) { |
| 37 | 40 | return $function; |
@@ -116,6 +119,9 @@ discard block |
||
| 116 | 119 | return '_wp_die_handler'; |
| 117 | 120 | } |
| 118 | 121 | |
| 122 | +/** |
|
| 123 | + * @param string $title |
|
| 124 | + */ |
|
| 119 | 125 | function _wp_die_handler_txt( $message, $title, $args ) { |
| 120 | 126 | echo "\nwp_die called\n"; |
| 121 | 127 | echo "Message : $message\n"; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | function _test_filter_build_unique_id($tag, $function, $priority) |
| 38 | 38 | { |
| 39 | 39 | if (is_string($function) ) { |
| 40 | - return $function; |
|
| 40 | + return $function; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if (is_object($function) ) { |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | $user_id = null; |
| 188 | 188 | $scheme = null; |
| 189 | 189 | /** |
| 190 | - * This action is documented in wp-inclues/pluggable.php |
|
| 190 | + * This action is documented in wp-inclues/pluggable.php |
|
| 191 | 191 | */ |
| 192 | 192 | do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme); |
| 193 | 193 | $logged_in_cookie = null; |
| 194 | 194 | /** |
| 195 | - * This action is documented in wp-inclues/pluggable.php |
|
| 195 | + * This action is documented in wp-inclues/pluggable.php |
|
| 196 | 196 | */ |
| 197 | 197 | do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in'); |
| 198 | 198 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | function wp_clear_auth_cookie() |
| 201 | 201 | { |
| 202 | 202 | /** |
| 203 | - * This action is documented in wp-inclues/pluggable.php |
|
| 203 | + * This action is documented in wp-inclues/pluggable.php |
|
| 204 | 204 | */ |
| 205 | 205 | do_action('clear_auth_cookie'); |
| 206 | 206 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | global $wp_filter; |
| 27 | 27 | |
| 28 | - if (function_exists('add_filter') ) { |
|
| 28 | + if (function_exists('add_filter')) { |
|
| 29 | 29 | add_filter($tag, $function_to_add, $priority, $accepted_args); |
| 30 | 30 | } else { |
| 31 | 31 | $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority); |
@@ -36,22 +36,22 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | function _test_filter_build_unique_id($tag, $function, $priority) |
| 38 | 38 | { |
| 39 | - if (is_string($function) ) { |
|
| 39 | + if (is_string($function)) { |
|
| 40 | 40 | return $function; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if (is_object($function) ) { |
|
| 43 | + if (is_object($function)) { |
|
| 44 | 44 | // Closures are currently implemented as objects |
| 45 | - $function = array( $function, '' ); |
|
| 45 | + $function = array($function, ''); |
|
| 46 | 46 | } else { |
| 47 | 47 | $function = (array) $function; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (is_object($function[0]) ) { |
|
| 50 | + if (is_object($function[0])) { |
|
| 51 | 51 | return spl_object_hash($function[0]) . $function[1]; |
| 52 | - } else if (is_string($function[0]) ) { |
|
| 52 | + } else if (is_string($function[0])) { |
|
| 53 | 53 | // Static Calling |
| 54 | - return $function[0].$function[1]; |
|
| 54 | + return $function[0] . $function[1]; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -59,21 +59,21 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | global $wpdb; |
| 61 | 61 | |
| 62 | - foreach ( array( |
|
| 62 | + foreach (array( |
|
| 63 | 63 | $wpdb->posts, |
| 64 | 64 | $wpdb->postmeta, |
| 65 | 65 | $wpdb->comments, |
| 66 | 66 | $wpdb->commentmeta, |
| 67 | 67 | $wpdb->term_relationships, |
| 68 | 68 | $wpdb->termmeta |
| 69 | - ) as $table ) { |
|
| 69 | + ) as $table) { |
|
| 70 | 70 | $wpdb->query("DELETE FROM {$table}"); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - foreach ( array( |
|
| 73 | + foreach (array( |
|
| 74 | 74 | $wpdb->terms, |
| 75 | 75 | $wpdb->term_taxonomy |
| 76 | - ) as $table ) { |
|
| 76 | + ) as $table) { |
|
| 77 | 77 | $wpdb->query("DELETE FROM {$table} WHERE term_id != 1"); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | global $wpdb; |
| 89 | 89 | |
| 90 | 90 | $all_posts = $wpdb->get_results("SELECT ID, post_type from {$wpdb->posts}", ARRAY_A); |
| 91 | - if (! $all_posts ) { |
|
| 91 | + if ( ! $all_posts) { |
|
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - foreach ( $all_posts as $data ) { |
|
| 96 | - if ('attachment' === $data['post_type'] ) { |
|
| 95 | + foreach ($all_posts as $data) { |
|
| 96 | + if ('attachment' === $data['post_type']) { |
|
| 97 | 97 | wp_delete_attachment($data['ID'], true); |
| 98 | 98 | } else { |
| 99 | 99 | wp_delete_post($data['ID'], true); |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function _wp_die_handler( $message, $title = '', $args = array() ) |
|
| 104 | +function _wp_die_handler($message, $title = '', $args = array()) |
|
| 105 | 105 | { |
| 106 | - if (!$GLOBALS['_wp_die_disabled'] ) { |
|
| 106 | + if ( ! $GLOBALS['_wp_die_disabled']) { |
|
| 107 | 107 | _wp_die_handler_txt($message, $title, $args); |
| 108 | 108 | } else { |
| 109 | 109 | //Ignore at our peril |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | return '_wp_die_handler'; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | -function _wp_die_handler_txt( $message, $title, $args ) |
|
| 128 | +function _wp_die_handler_txt($message, $title, $args) |
|
| 129 | 129 | { |
| 130 | 130 | echo "\nwp_die called\n"; |
| 131 | 131 | echo "Message : $message\n"; |
| 132 | 132 | echo "Title : $title\n"; |
| 133 | - if (! empty($args) ) { |
|
| 133 | + if ( ! empty($args)) { |
|
| 134 | 134 | echo "Args: \n"; |
| 135 | - foreach( $args as $k => $v ){ |
|
| 135 | + foreach ($args as $k => $v) { |
|
| 136 | 136 | echo "\t $k : $v\n"; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * Helper used with the `upload_dir` filter to remove the /year/month sub directories from the uploads path and URL. |
| 156 | 156 | */ |
| 157 | -function _upload_dir_no_subdir( $uploads ) |
|
| 157 | +function _upload_dir_no_subdir($uploads) |
|
| 158 | 158 | { |
| 159 | 159 | $subdir = $uploads['subdir']; |
| 160 | 160 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | /** |
| 169 | 169 | * Helper used with the `upload_dir` filter to set https upload URL. |
| 170 | 170 | */ |
| 171 | -function _upload_dir_https( $uploads ) |
|
| 171 | +function _upload_dir_https($uploads) |
|
| 172 | 172 | { |
| 173 | 173 | $uploads['url'] = str_replace('http://', 'https://', $uploads['url']); |
| 174 | 174 | $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | // Skip `setcookie` calls in auth_cookie functions due to warning: |
| 180 | 180 | // Cannot modify header information - headers already sent by ... |
| 181 | 181 | |
| 182 | -function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) |
|
| 182 | +function wp_set_auth_cookie($user_id, $remember = false, $secure = '', $token = '') |
|
| 183 | 183 | { |
| 184 | 184 | $auth_cookie = null; |
| 185 | 185 | $expire = null; |
@@ -6,6 +6,9 @@ discard block |
||
| 6 | 6 | return substr(md5(uniqid(rand())), 0, $len); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | +/** |
|
| 10 | + * @param integer $length |
|
| 11 | + */ |
|
| 9 | 12 | function rand_long_str( $length ) { |
| 10 | 13 | $chars = 'abcdefghijklmnopqrstuvwxyz'; |
| 11 | 14 | $string = ''; |
@@ -203,6 +206,9 @@ discard block |
||
| 203 | 206 | } |
| 204 | 207 | } |
| 205 | 208 | |
| 209 | +/** |
|
| 210 | + * @param string $in |
|
| 211 | + */ |
|
| 206 | 212 | function xml_to_array($in) { |
| 207 | 213 | $p = new testXMLParser($in); |
| 208 | 214 | return $p->data; |
@@ -338,6 +344,9 @@ discard block |
||
| 338 | 344 | } |
| 339 | 345 | |
| 340 | 346 | // mask out any input fields matching the given name |
| 347 | +/** |
|
| 348 | + * @param string $in |
|
| 349 | + */ |
|
| 341 | 350 | function mask_input_value($in, $name='_wpnonce') { |
| 342 | 351 | return preg_replace('@<input([^>]*) name="'.preg_quote($name).'"([^>]*) value="[^>]*" />@', '<input$1 name="'.preg_quote($name).'"$2 value="***" />', $in); |
| 343 | 352 | } |
@@ -425,6 +434,7 @@ discard block |
||
| 425 | 434 | /** |
| 426 | 435 | * Determine approximate backtrack count when running PCRE. |
| 427 | 436 | * |
| 437 | + * @param string $strategy |
|
| 428 | 438 | * @return int The backtrack count. |
| 429 | 439 | */ |
| 430 | 440 | function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | function current_filter() |
| 61 | 61 | { |
| 62 | 62 | if (is_callable('current_filter')) { |
| 63 | - return current_filter(); |
|
| 63 | + return current_filter(); |
|
| 64 | 64 | } |
| 65 | 65 | global $wp_actions; |
| 66 | 66 | return end($wp_actions); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $out = array(); |
| 169 | 169 | foreach ($this->events as $e) { |
| 170 | - $out[] = $e['args']; |
|
| 170 | + $out[] = $e['args']; |
|
| 171 | 171 | } |
| 172 | 172 | return $out; |
| 173 | 173 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $out = array(); |
| 248 | 248 | |
| 249 | 249 | if ($n < 1) { |
| 250 | - return $out; |
|
| 250 | + return $out; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | for ($i=0; $i<count($tree); $i++) { |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $a = array(); |
| 275 | 275 | foreach ($atts as $k=>$v) { |
| 276 | - $a[] = $k.'="'.$v.'"'; |
|
| 276 | + $a[] = $k.'="'.$v.'"'; |
|
| 277 | 277 | } |
| 278 | 278 | return join(' ', $a); |
| 279 | 279 | } |
@@ -285,13 +285,13 @@ discard block |
||
| 285 | 285 | foreach (array_keys($data) as $i) { |
| 286 | 286 | $name = $data[$i]['name']; |
| 287 | 287 | if (!empty($data[$i]['attributes'])) { |
| 288 | - $name .= ' '.xml_join_atts($data[$i]['attributes']); |
|
| 288 | + $name .= ' '.xml_join_atts($data[$i]['attributes']); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | if (!empty($data[$i]['child'])) { |
| 292 | 292 | $out[$name][] = xml_array_dumbdown($data[$i]['child']); |
| 293 | 293 | } else { |
| 294 | - $out[$name] = $data[$i]['content']; |
|
| 294 | + $out[$name] = $data[$i]['content']; |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $args = func_get_args(); |
| 304 | 304 | |
| 305 | 305 | foreach ($args as $thing) { |
| 306 | - echo (is_scalar($thing) ? strval($thing) : var_export($thing, true)), "\n"; |
|
| 306 | + echo (is_scalar($thing) ? strval($thing) : var_export($thing, true)), "\n"; |
|
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | $out = array(); |
| 327 | 327 | foreach ($array as $k=>$v) { |
| 328 | 328 | if (is_numeric($k)) { |
| 329 | - $index = strval($k); |
|
| 329 | + $index = strval($k); |
|
| 330 | 330 | } else { |
| 331 | - $index = "'".addcslashes($k, "\n\r\t'\\")."'"; |
|
| 331 | + $index = "'".addcslashes($k, "\n\r\t'\\")."'"; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | if (is_string($v)) { |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | global $wpdb; |
| 358 | 358 | $tables = $wpdb->get_col('SHOW TABLES;'); |
| 359 | 359 | foreach ($tables as $table) { |
| 360 | - $wpdb->query("DROP TABLE IF EXISTS {$table}"); |
|
| 360 | + $wpdb->query("DROP TABLE IF EXISTS {$table}"); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
@@ -369,10 +369,10 @@ discard block |
||
| 369 | 369 | foreach ($bt as $stack) { |
| 370 | 370 | echo ++$i, ": "; |
| 371 | 371 | if (isset($stack['class']) ) { |
| 372 | - echo $stack['class'].'::'; |
|
| 372 | + echo $stack['class'].'::'; |
|
| 373 | 373 | } |
| 374 | 374 | if (isset($stack['function']) ) { |
| 375 | - echo $stack['function'].'() '; |
|
| 375 | + echo $stack['function'].'() '; |
|
| 376 | 376 | } |
| 377 | 377 | echo "line {$stack[line]} in {$stack[file]}\n"; |
| 378 | 378 | } |
@@ -426,22 +426,22 @@ discard block |
||
| 426 | 426 | { |
| 427 | 427 | // clean out globals to stop them polluting wp and wp_query |
| 428 | 428 | foreach ( $GLOBALS['wp']->public_query_vars as $v ) { |
| 429 | - unset($GLOBALS[$v]); |
|
| 429 | + unset($GLOBALS[$v]); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | foreach ( $GLOBALS['wp']->private_query_vars as $v ) { |
| 433 | - unset($GLOBALS[$v]); |
|
| 433 | + unset($GLOBALS[$v]); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | foreach ( get_taxonomies(array(), 'objects') as $t ) { |
| 437 | 437 | if ($t->publicly_queryable && ! empty($t->query_var) ) { |
| 438 | - $GLOBALS['wp']->add_query_var($t->query_var); |
|
| 438 | + $GLOBALS['wp']->add_query_var($t->query_var); |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | foreach ( get_post_types(array(), 'objects') as $t ) { |
| 443 | 443 | if (is_post_type_viewable($t) && ! empty($t->query_var) ) { |
| 444 | - $GLOBALS['wp']->add_query_var($t->query_var); |
|
| 444 | + $GLOBALS['wp']->add_query_var($t->query_var); |
|
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -496,37 +496,37 @@ |
||
| 496 | 496 | ini_set('pcre.backtrack_limit', $i); |
| 497 | 497 | |
| 498 | 498 | switch( $strategy ) { |
| 499 | - case 'split': |
|
| 500 | - preg_split($pattern, $subject); |
|
| 501 | - break; |
|
| 502 | - case 'match': |
|
| 503 | - preg_match($pattern, $subject); |
|
| 504 | - break; |
|
| 505 | - case 'match_all': |
|
| 506 | - $matches = array(); |
|
| 507 | - preg_match_all($pattern, $subject, $matches); |
|
| 508 | - break; |
|
| 499 | + case 'split': |
|
| 500 | + preg_split($pattern, $subject); |
|
| 501 | + break; |
|
| 502 | + case 'match': |
|
| 503 | + preg_match($pattern, $subject); |
|
| 504 | + break; |
|
| 505 | + case 'match_all': |
|
| 506 | + $matches = array(); |
|
| 507 | + preg_match_all($pattern, $subject, $matches); |
|
| 508 | + break; |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | ini_set('pcre.backtrack_limit', $saved_config); |
| 512 | 512 | |
| 513 | 513 | switch( preg_last_error() ) { |
| 514 | - case PREG_NO_ERROR: |
|
| 515 | - return $i; |
|
| 516 | - case PREG_BACKTRACK_LIMIT_ERROR: |
|
| 517 | - continue; |
|
| 518 | - case PREG_RECURSION_LIMIT_ERROR: |
|
| 519 | - trigger_error('PCRE recursion limit encountered before backtrack limit.'); |
|
| 520 | - return; |
|
| 521 | - case PREG_BAD_UTF8_ERROR: |
|
| 522 | - trigger_error('UTF-8 error during PCRE benchmark.'); |
|
| 523 | - return; |
|
| 524 | - case PREG_INTERNAL_ERROR: |
|
| 525 | - trigger_error('Internal error during PCRE benchmark.'); |
|
| 526 | - return; |
|
| 527 | - default: |
|
| 528 | - trigger_error('Unexpected error during PCRE benchmark.'); |
|
| 529 | - return; |
|
| 514 | + case PREG_NO_ERROR: |
|
| 515 | + return $i; |
|
| 516 | + case PREG_BACKTRACK_LIMIT_ERROR: |
|
| 517 | + continue; |
|
| 518 | + case PREG_RECURSION_LIMIT_ERROR: |
|
| 519 | + trigger_error('PCRE recursion limit encountered before backtrack limit.'); |
|
| 520 | + return; |
|
| 521 | + case PREG_BAD_UTF8_ERROR: |
|
| 522 | + trigger_error('UTF-8 error during PCRE benchmark.'); |
|
| 523 | + return; |
|
| 524 | + case PREG_INTERNAL_ERROR: |
|
| 525 | + trigger_error('Internal error during PCRE benchmark.'); |
|
| 526 | + return; |
|
| 527 | + default: |
|
| 528 | + trigger_error('Unexpected error during PCRE benchmark.'); |
|
| 529 | + return; |
|
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | |
@@ -2,17 +2,17 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | // misc help functions and utilities |
| 4 | 4 | |
| 5 | -function rand_str($len=32) |
|
| 5 | +function rand_str($len = 32) |
|
| 6 | 6 | { |
| 7 | 7 | return substr(md5(uniqid(rand())), 0, $len); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -function rand_long_str( $length ) |
|
| 10 | +function rand_long_str($length) |
|
| 11 | 11 | { |
| 12 | 12 | $chars = 'abcdefghijklmnopqrstuvwxyz'; |
| 13 | 13 | $string = ''; |
| 14 | 14 | |
| 15 | - for ( $i = 0; $i < $length; $i++ ) { |
|
| 15 | + for ($i = 0; $i < $length; $i++) { |
|
| 16 | 16 | $rand = rand(0, strlen($chars) - 1); |
| 17 | 17 | $string .= substr($chars, $rand, 1); |
| 18 | 18 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * PHP5 constructor. |
| 48 | 48 | */ |
| 49 | - function __construct( $debug = 0 ) |
|
| 49 | + function __construct($debug = 0) |
|
| 50 | 50 | { |
| 51 | 51 | $this->reset(); |
| 52 | 52 | $this->debug = $debug; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | return $arg . '_append'; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - function filterall($tag, $arg=null) |
|
| 123 | + function filterall($tag, $arg = null) |
|
| 124 | 124 | { |
| 125 | 125 | // this one doesn't return the result, so it's safe to use with the new 'all' filter |
| 126 | 126 | if ($this->debug) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // return a count of the number of times the action was called since the last reset |
| 141 | - function get_call_count($tag='') |
|
| 141 | + function get_call_count($tag = '') |
|
| 142 | 142 | { |
| 143 | 143 | if ($tag) { |
| 144 | 144 | $count = 0; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | /** |
| 184 | 184 | * PHP5 constructor. |
| 185 | 185 | */ |
| 186 | - function __construct( $in ) |
|
| 186 | + function __construct($in) |
|
| 187 | 187 | { |
| 188 | 188 | $this->xml = xml_parser_create(); |
| 189 | 189 | xml_set_object($this->xml, $this); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | function parse($in) |
| 197 | 197 | { |
| 198 | 198 | $parse = xml_parse($this->xml, $in, sizeof($in)); |
| 199 | - if (!$parse) { |
|
| 199 | + if ( ! $parse) { |
|
| 200 | 200 | trigger_error( |
| 201 | 201 | sprintf( |
| 202 | 202 | "XML error: %s at line %d", |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | return $out; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - for ($i=0; $i<count($tree); $i++) { |
|
| 253 | + for ($i = 0; $i < count($tree); $i++) { |
|
| 254 | 254 | // echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n"; |
| 255 | 255 | // var_dump($tree[$i]['name'], $a[0]); |
| 256 | 256 | if ($tree[$i]['name'] == $a[0]) { |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | if ($n == 1) { |
| 259 | 259 | $out[] = $tree[$i]; |
| 260 | 260 | } else { |
| 261 | - $subtree =& $tree[$i]['child']; |
|
| 261 | + $subtree = & $tree[$i]['child']; |
|
| 262 | 262 | $call_args = array($subtree); |
| 263 | 263 | $call_args = array_merge($call_args, array_slice($a, 1)); |
| 264 | 264 | $out = array_merge($out, call_user_func_array('xml_find', $call_args)); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $a = array(); |
| 275 | 275 | foreach ($atts as $k=>$v) { |
| 276 | - $a[] = $k.'="'.$v.'"'; |
|
| 276 | + $a[] = $k . '="' . $v . '"'; |
|
| 277 | 277 | } |
| 278 | 278 | return join(' ', $a); |
| 279 | 279 | } |
@@ -284,11 +284,11 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | foreach (array_keys($data) as $i) { |
| 286 | 286 | $name = $data[$i]['name']; |
| 287 | - if (!empty($data[$i]['attributes'])) { |
|
| 288 | - $name .= ' '.xml_join_atts($data[$i]['attributes']); |
|
| 287 | + if ( ! empty($data[$i]['attributes'])) { |
|
| 288 | + $name .= ' ' . xml_join_atts($data[$i]['attributes']); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if (!empty($data[$i]['child'])) { |
|
| 291 | + if ( ! empty($data[$i]['child'])) { |
|
| 292 | 292 | $out[$name][] = xml_array_dumbdown($data[$i]['child']); |
| 293 | 293 | } else { |
| 294 | 294 | $out[$name] = $data[$i]['content']; |
@@ -328,18 +328,18 @@ discard block |
||
| 328 | 328 | if (is_numeric($k)) { |
| 329 | 329 | $index = strval($k); |
| 330 | 330 | } else { |
| 331 | - $index = "'".addcslashes($k, "\n\r\t'\\")."'"; |
|
| 331 | + $index = "'" . addcslashes($k, "\n\r\t'\\") . "'"; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | if (is_string($v)) { |
| 335 | - $out[] = '$this->assertEquals( \'' . addcslashes($v, "\n\r\t'\\") . '\', $'.$name.'['.$index.'] );'; |
|
| 335 | + $out[] = '$this->assertEquals( \'' . addcslashes($v, "\n\r\t'\\") . '\', $' . $name . '[' . $index . '] );'; |
|
| 336 | 336 | } elseif (is_numeric($v)) { |
| 337 | - $out[] = '$this->assertEquals( ' . $v . ', $'.$name.'['.$index.'] );'; |
|
| 337 | + $out[] = '$this->assertEquals( ' . $v . ', $' . $name . '[' . $index . '] );'; |
|
| 338 | 338 | } elseif (is_array($v)) { |
| 339 | 339 | $out[] = gen_tests_array("{$name}[{$index}]", $v); |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | - return join("\n", $out)."\n"; |
|
| 342 | + return join("\n", $out) . "\n"; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -368,11 +368,11 @@ discard block |
||
| 368 | 368 | $i = 0; |
| 369 | 369 | foreach ($bt as $stack) { |
| 370 | 370 | echo ++$i, ": "; |
| 371 | - if (isset($stack['class']) ) { |
|
| 372 | - echo $stack['class'].'::'; |
|
| 371 | + if (isset($stack['class'])) { |
|
| 372 | + echo $stack['class'] . '::'; |
|
| 373 | 373 | } |
| 374 | - if (isset($stack['function']) ) { |
|
| 375 | - echo $stack['function'].'() '; |
|
| 374 | + if (isset($stack['function'])) { |
|
| 375 | + echo $stack['function'] . '() '; |
|
| 376 | 376 | } |
| 377 | 377 | echo "line {$stack[line]} in {$stack[file]}\n"; |
| 378 | 378 | } |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | // mask out any input fields matching the given name |
| 383 | -function mask_input_value($in, $name='_wpnonce') |
|
| 383 | +function mask_input_value($in, $name = '_wpnonce') |
|
| 384 | 384 | { |
| 385 | - return preg_replace('@<input([^>]*) name="'.preg_quote($name).'"([^>]*) value="[^>]*" />@', '<input$1 name="'.preg_quote($name).'"$2 value="***" />', $in); |
|
| 385 | + return preg_replace('@<input([^>]*) name="' . preg_quote($name) . '"([^>]*) value="[^>]*" />@', '<input$1 name="' . preg_quote($name) . '"$2 value="***" />', $in); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -if (!function_exists('str_getcsv') ) { |
|
| 389 | - function str_getcsv( $input, $delimiter = ',', $enclosure = '"', $escape = "\\" ) |
|
| 388 | +if ( ! function_exists('str_getcsv')) { |
|
| 389 | + function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = "\\") |
|
| 390 | 390 | { |
| 391 | 391 | $fp = fopen('php://temp/', 'r+'); |
| 392 | 392 | fputs($fp, $input); |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | /** |
| 401 | 401 | * Removes the post type and its taxonomy associations. |
| 402 | 402 | */ |
| 403 | -function _unregister_post_type( $cpt_name ) |
|
| 403 | +function _unregister_post_type($cpt_name) |
|
| 404 | 404 | { |
| 405 | 405 | unregister_post_type($cpt_name); |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | -function _unregister_taxonomy( $taxonomy_name ) |
|
| 408 | +function _unregister_taxonomy($taxonomy_name) |
|
| 409 | 409 | { |
| 410 | 410 | unregister_taxonomy($taxonomy_name); |
| 411 | 411 | } |
@@ -417,30 +417,30 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * @param string $status |
| 419 | 419 | */ |
| 420 | -function _unregister_post_status( $status ) |
|
| 420 | +function _unregister_post_status($status) |
|
| 421 | 421 | { |
| 422 | - unset($GLOBALS['wp_post_statuses'][ $status ]); |
|
| 422 | + unset($GLOBALS['wp_post_statuses'][$status]); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | function _cleanup_query_vars() |
| 426 | 426 | { |
| 427 | 427 | // clean out globals to stop them polluting wp and wp_query |
| 428 | - foreach ( $GLOBALS['wp']->public_query_vars as $v ) { |
|
| 428 | + foreach ($GLOBALS['wp']->public_query_vars as $v) { |
|
| 429 | 429 | unset($GLOBALS[$v]); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - foreach ( $GLOBALS['wp']->private_query_vars as $v ) { |
|
| 432 | + foreach ($GLOBALS['wp']->private_query_vars as $v) { |
|
| 433 | 433 | unset($GLOBALS[$v]); |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - foreach ( get_taxonomies(array(), 'objects') as $t ) { |
|
| 437 | - if ($t->publicly_queryable && ! empty($t->query_var) ) { |
|
| 436 | + foreach (get_taxonomies(array(), 'objects') as $t) { |
|
| 437 | + if ($t->publicly_queryable && ! empty($t->query_var)) { |
|
| 438 | 438 | $GLOBALS['wp']->add_query_var($t->query_var); |
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - foreach ( get_post_types(array(), 'objects') as $t ) { |
|
| 443 | - if (is_post_type_viewable($t) && ! empty($t->query_var) ) { |
|
| 442 | + foreach (get_post_types(array(), 'objects') as $t) { |
|
| 443 | + if (is_post_type_viewable($t) && ! empty($t->query_var)) { |
|
| 444 | 444 | $GLOBALS['wp']->add_query_var($t->query_var); |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | function _clean_term_filters() |
| 450 | 450 | { |
| 451 | - remove_filter('get_terms', array( 'Featured_Content', 'hide_featured_term' ), 10, 2); |
|
| 452 | - remove_filter('get_the_terms', array( 'Featured_Content', 'hide_the_featured_term' ), 10, 3); |
|
| 451 | + remove_filter('get_terms', array('Featured_Content', 'hide_featured_term'), 10, 2); |
|
| 452 | + remove_filter('get_the_terms', array('Featured_Content', 'hide_the_featured_term'), 10, 3); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -468,9 +468,9 @@ discard block |
||
| 468 | 468 | $this->charset = $wpdb->charset; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - public function __call( $name, $arguments ) |
|
| 471 | + public function __call($name, $arguments) |
|
| 472 | 472 | { |
| 473 | - return call_user_func_array(array( $this, $name ), $arguments); |
|
| 473 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | 476 | |
@@ -479,23 +479,23 @@ discard block |
||
| 479 | 479 | * |
| 480 | 480 | * @return int The backtrack count. |
| 481 | 481 | */ |
| 482 | -function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) |
|
| 482 | +function benchmark_pcre_backtracking($pattern, $subject, $strategy) |
|
| 483 | 483 | { |
| 484 | 484 | $saved_config = ini_get('pcre.backtrack_limit'); |
| 485 | 485 | |
| 486 | 486 | // Attempt to prevent PHP crashes. Adjust these lower when needed. |
| 487 | - if (version_compare(phpversion(), '5.4.8', '>') ) { |
|
| 487 | + if (version_compare(phpversion(), '5.4.8', '>')) { |
|
| 488 | 488 | $limit = 1000000; |
| 489 | 489 | } else { |
| 490 | - $limit = 20000; // 20,000 is a reasonable upper limit, but see also https://core.trac.wordpress.org/ticket/29557#comment:10 |
|
| 490 | + $limit = 20000; // 20,000 is a reasonable upper limit, but see also https://core.trac.wordpress.org/ticket/29557#comment:10 |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | // Start with small numbers, so if a crash is encountered at higher numbers we can still debug the problem. |
| 494 | - for( $i = 4; $i <= $limit; $i *= 2 ) { |
|
| 494 | + for ($i = 4; $i <= $limit; $i *= 2) { |
|
| 495 | 495 | |
| 496 | 496 | ini_set('pcre.backtrack_limit', $i); |
| 497 | 497 | |
| 498 | - switch( $strategy ) { |
|
| 498 | + switch ($strategy) { |
|
| 499 | 499 | case 'split': |
| 500 | 500 | preg_split($pattern, $subject); |
| 501 | 501 | break; |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | ini_set('pcre.backtrack_limit', $saved_config); |
| 512 | 512 | |
| 513 | - switch( preg_last_error() ) { |
|
| 513 | + switch (preg_last_error()) { |
|
| 514 | 514 | case PREG_NO_ERROR: |
| 515 | 515 | return $i; |
| 516 | 516 | case PREG_BACKTRACK_LIMIT_ERROR: |
@@ -533,22 +533,22 @@ discard block |
||
| 533 | 533 | return $i; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | -function test_rest_expand_compact_links( $links ) |
|
| 536 | +function test_rest_expand_compact_links($links) |
|
| 537 | 537 | { |
| 538 | - if (empty($links['curies']) ) { |
|
| 538 | + if (empty($links['curies'])) { |
|
| 539 | 539 | return $links; |
| 540 | 540 | } |
| 541 | - foreach ( $links as $rel => $links_array ) { |
|
| 542 | - if (! strpos($rel, ':') ) { |
|
| 541 | + foreach ($links as $rel => $links_array) { |
|
| 542 | + if ( ! strpos($rel, ':')) { |
|
| 543 | 543 | continue; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | $name = explode(':', $rel); |
| 547 | 547 | |
| 548 | - $curie = wp_list_filter($links['curies'], array( 'name' => $name[0] )); |
|
| 548 | + $curie = wp_list_filter($links['curies'], array('name' => $name[0])); |
|
| 549 | 549 | $full_uri = str_replace('{rel}', $name[1], $curie[0]['href']); |
| 550 | - $links[ $full_uri ] = $links_array; |
|
| 551 | - unset($links[ $rel ]); |
|
| 550 | + $links[$full_uri] = $links_array; |
|
| 551 | + unset($links[$rel]); |
|
| 552 | 552 | } |
| 553 | 553 | return $links; |
| 554 | 554 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function endTest(PHPUnit_Framework_Test $test, $time) |
| 135 | 135 | { |
| 136 | - if (!$test instanceof PHPUnit_Framework_TestCase) { |
|
| 136 | + if ( ! $test instanceof PHPUnit_Framework_TestCase) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | protected function hasSlowTests() |
| 207 | 207 | { |
| 208 | - return !empty($this->slow); |
|
| 208 | + return ! empty($this->slow); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -6,11 +6,11 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | $config_file_path = dirname( dirname( __FILE__ ) ); |
| 8 | 8 | if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) { |
| 9 | - // Support the config file from the root of the develop repository. |
|
| 10 | - if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) { |
|
| 11 | - $config_file_path = dirname( dirname( $config_file_path ) ); |
|
| 12 | - } |
|
| 13 | - } |
|
| 9 | + // Support the config file from the root of the develop repository. |
|
| 10 | + if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) { |
|
| 11 | + $config_file_path = dirname( dirname( $config_file_path ) ); |
|
| 12 | + } |
|
| 13 | + } |
|
| 14 | 14 | $config_file_path .= '/wp-tests-config.php'; |
| 15 | 15 | |
| 16 | 16 | /* |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories; |
| 21 | 21 | |
| 22 | 22 | if ( !is_readable( $config_file_path ) ) { |
| 23 | - die( "ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n" ); |
|
| 23 | + die( "ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n" ); |
|
| 24 | 24 | } |
| 25 | 25 | require_once $config_file_path; |
| 26 | 26 | require_once dirname( __FILE__ ) . '/functions.php'; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' ); |
| 34 | 34 | |
| 35 | 35 | if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) { |
| 36 | - define( 'WP_TESTS_FORCE_KNOWN_BUGS', false ); |
|
| 36 | + define( 'WP_TESTS_FORCE_KNOWN_BUGS', false ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | $phpmailer = new MockPHPMailer( true ); |
| 57 | 57 | |
| 58 | 58 | if ( ! defined( 'WP_DEFAULT_THEME' ) ) { |
| 59 | - define( 'WP_DEFAULT_THEME', 'default' ); |
|
| 59 | + define( 'WP_DEFAULT_THEME', 'default' ); |
|
| 60 | 60 | } |
| 61 | 61 | $wp_theme_directories = array( DIR_TESTDATA . '/themedir1' ); |
| 62 | 62 | |
| 63 | 63 | system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite ); |
| 64 | 64 | |
| 65 | 65 | if ( $multisite ) { |
| 66 | - echo "Running as multisite..." . PHP_EOL; |
|
| 67 | - defined( 'MULTISITE' ) or define( 'MULTISITE', true ); |
|
| 68 | - defined( 'SUBDOMAIN_INSTALL' ) or define( 'SUBDOMAIN_INSTALL', false ); |
|
| 69 | - $GLOBALS['base'] = '/'; |
|
| 66 | + echo "Running as multisite..." . PHP_EOL; |
|
| 67 | + defined( 'MULTISITE' ) or define( 'MULTISITE', true ); |
|
| 68 | + defined( 'SUBDOMAIN_INSTALL' ) or define( 'SUBDOMAIN_INSTALL', false ); |
|
| 69 | + $GLOBALS['base'] = '/'; |
|
| 70 | 70 | } else { |
| 71 | - echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL; |
|
| 71 | + echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL; |
|
| 72 | 72 | } |
| 73 | 73 | unset( $multisite ); |
| 74 | 74 | |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | // Preset WordPress options defined in bootstrap file. |
| 80 | 80 | // Used to activate themes, plugins, as well as other settings. |
| 81 | 81 | if(isset($GLOBALS['wp_tests_options'])) { |
| 82 | - function wp_tests_options( $value ) { |
|
| 83 | - $key = substr( current_filter(), strlen( 'pre_option_' ) ); |
|
| 84 | - return $GLOBALS['wp_tests_options'][$key]; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - foreach ( array_keys( $GLOBALS['wp_tests_options'] ) as $key ) { |
|
| 88 | - tests_add_filter( 'pre_option_'.$key, 'wp_tests_options' ); |
|
| 89 | - } |
|
| 82 | + function wp_tests_options( $value ) { |
|
| 83 | + $key = substr( current_filter(), strlen( 'pre_option_' ) ); |
|
| 84 | + return $GLOBALS['wp_tests_options'][$key]; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + foreach ( array_keys( $GLOBALS['wp_tests_options'] ) as $key ) { |
|
| 88 | + tests_add_filter( 'pre_option_'.$key, 'wp_tests_options' ); |
|
| 89 | + } |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Load WordPress |
@@ -120,66 +120,66 @@ discard block |
||
| 120 | 120 | * how you call phpunit has no effect. |
| 121 | 121 | */ |
| 122 | 122 | class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt { |
| 123 | - protected $longOptions = array( |
|
| 124 | - 'exclude-group=', |
|
| 125 | - 'group=', |
|
| 126 | - ); |
|
| 127 | - function __construct( $argv ) { |
|
| 128 | - array_shift( $argv ); |
|
| 129 | - $options = array(); |
|
| 130 | - while ( list( $i, $arg ) = each( $argv ) ) { |
|
| 131 | - try { |
|
| 132 | - if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { |
|
| 133 | - PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); |
|
| 134 | - } |
|
| 135 | - } catch ( PHPUnit_Framework_Exception $e ) { |
|
| 136 | - // Enforcing recognized arguments or correctly formed arguments is |
|
| 137 | - // not really the concern here. |
|
| 138 | - continue; |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $skipped_groups = array( |
|
| 143 | - 'ajax' => true, |
|
| 144 | - 'ms-files' => true, |
|
| 145 | - 'external-http' => true, |
|
| 146 | - ); |
|
| 147 | - |
|
| 148 | - foreach ( $options as $option ) { |
|
| 149 | - switch ( $option[0] ) { |
|
| 150 | - case '--exclude-group' : |
|
| 151 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 152 | - $skipped_groups[ $group_name ] = false; |
|
| 153 | - } |
|
| 154 | - continue 2; |
|
| 155 | - case '--group' : |
|
| 156 | - $groups = explode( ',', $option[1] ); |
|
| 157 | - foreach ( $groups as $group ) { |
|
| 158 | - if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) { |
|
| 159 | - WP_UnitTestCase::forceTicket( $group ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 164 | - if ( in_array( $group_name, $groups ) ) { |
|
| 165 | - $skipped_groups[ $group_name ] = false; |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - continue 2; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - $skipped_groups = array_filter( $skipped_groups ); |
|
| 173 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 174 | - echo sprintf( 'Not running %1$s tests. To execute these, use --group %1$s.', $group_name ) . PHP_EOL; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - if ( ! isset( $skipped_groups['external-http'] ) ) { |
|
| 178 | - echo PHP_EOL; |
|
| 179 | - echo 'External HTTP skipped tests can be caused by timeouts.' . PHP_EOL; |
|
| 180 | - echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL; |
|
| 181 | - echo PHP_EOL; |
|
| 182 | - } |
|
| 123 | + protected $longOptions = array( |
|
| 124 | + 'exclude-group=', |
|
| 125 | + 'group=', |
|
| 126 | + ); |
|
| 127 | + function __construct( $argv ) { |
|
| 128 | + array_shift( $argv ); |
|
| 129 | + $options = array(); |
|
| 130 | + while ( list( $i, $arg ) = each( $argv ) ) { |
|
| 131 | + try { |
|
| 132 | + if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { |
|
| 133 | + PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); |
|
| 134 | + } |
|
| 135 | + } catch ( PHPUnit_Framework_Exception $e ) { |
|
| 136 | + // Enforcing recognized arguments or correctly formed arguments is |
|
| 137 | + // not really the concern here. |
|
| 138 | + continue; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $skipped_groups = array( |
|
| 143 | + 'ajax' => true, |
|
| 144 | + 'ms-files' => true, |
|
| 145 | + 'external-http' => true, |
|
| 146 | + ); |
|
| 147 | + |
|
| 148 | + foreach ( $options as $option ) { |
|
| 149 | + switch ( $option[0] ) { |
|
| 150 | + case '--exclude-group' : |
|
| 151 | + foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 152 | + $skipped_groups[ $group_name ] = false; |
|
| 153 | + } |
|
| 154 | + continue 2; |
|
| 155 | + case '--group' : |
|
| 156 | + $groups = explode( ',', $option[1] ); |
|
| 157 | + foreach ( $groups as $group ) { |
|
| 158 | + if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) { |
|
| 159 | + WP_UnitTestCase::forceTicket( $group ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 164 | + if ( in_array( $group_name, $groups ) ) { |
|
| 165 | + $skipped_groups[ $group_name ] = false; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + continue 2; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + $skipped_groups = array_filter( $skipped_groups ); |
|
| 173 | + foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 174 | + echo sprintf( 'Not running %1$s tests. To execute these, use --group %1$s.', $group_name ) . PHP_EOL; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + if ( ! isset( $skipped_groups['external-http'] ) ) { |
|
| 178 | + echo PHP_EOL; |
|
| 179 | + echo 'External HTTP skipped tests can be caused by timeouts.' . PHP_EOL; |
|
| 180 | + echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL; |
|
| 181 | + echo PHP_EOL; |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] ); |
@@ -4,11 +4,11 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -$config_file_path = dirname( dirname( __FILE__ ) ); |
|
| 8 | -if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) { |
|
| 7 | +$config_file_path = dirname(dirname(__FILE__)); |
|
| 8 | +if ( ! file_exists($config_file_path . '/wp-tests-config.php')) { |
|
| 9 | 9 | // Support the config file from the root of the develop repository. |
| 10 | - if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) { |
|
| 11 | - $config_file_path = dirname( dirname( $config_file_path ) ); |
|
| 10 | + if (basename($config_file_path) === 'phpunit' && basename(dirname($config_file_path)) === 'tests') { |
|
| 11 | + $config_file_path = dirname(dirname($config_file_path)); |
|
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | $config_file_path .= '/wp-tests-config.php'; |
@@ -19,73 +19,73 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories; |
| 21 | 21 | |
| 22 | -if ( !is_readable( $config_file_path ) ) { |
|
| 23 | - die( "ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n" ); |
|
| 22 | +if ( ! is_readable($config_file_path)) { |
|
| 23 | + die("ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n"); |
|
| 24 | 24 | } |
| 25 | 25 | require_once $config_file_path; |
| 26 | -require_once dirname( __FILE__ ) . '/functions.php'; |
|
| 26 | +require_once dirname(__FILE__) . '/functions.php'; |
|
| 27 | 27 | |
| 28 | 28 | tests_reset__SERVER(); |
| 29 | 29 | |
| 30 | -define( 'WP_TESTS_TABLE_PREFIX', $table_prefix ); |
|
| 31 | -define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' ); |
|
| 30 | +define('WP_TESTS_TABLE_PREFIX', $table_prefix); |
|
| 31 | +define('DIR_TESTDATA', dirname(__FILE__) . '/../data'); |
|
| 32 | 32 | |
| 33 | -define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' ); |
|
| 33 | +define('WP_LANG_DIR', DIR_TESTDATA . '/languages'); |
|
| 34 | 34 | |
| 35 | -if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) { |
|
| 36 | - define( 'WP_TESTS_FORCE_KNOWN_BUGS', false ); |
|
| 35 | +if ( ! defined('WP_TESTS_FORCE_KNOWN_BUGS')) { |
|
| 36 | + define('WP_TESTS_FORCE_KNOWN_BUGS', false); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only |
| 40 | -define( 'DISABLE_WP_CRON', true ); |
|
| 40 | +define('DISABLE_WP_CRON', true); |
|
| 41 | 41 | |
| 42 | -define( 'WP_MEMORY_LIMIT', -1 ); |
|
| 43 | -define( 'WP_MAX_MEMORY_LIMIT', -1 ); |
|
| 42 | +define('WP_MEMORY_LIMIT', -1); |
|
| 43 | +define('WP_MAX_MEMORY_LIMIT', -1); |
|
| 44 | 44 | |
| 45 | -define( 'REST_TESTS_IMPOSSIBLY_HIGH_NUMBER', 99999999 ); |
|
| 45 | +define('REST_TESTS_IMPOSSIBLY_HIGH_NUMBER', 99999999); |
|
| 46 | 46 | |
| 47 | 47 | $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php'; |
| 48 | 48 | |
| 49 | 49 | // Should we run in multisite mode? |
| 50 | -$multisite = '1' == getenv( 'WP_MULTISITE' ); |
|
| 51 | -$multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE ); |
|
| 52 | -$multisite = $multisite || ( defined( 'MULTISITE' ) && MULTISITE ); |
|
| 50 | +$multisite = '1' == getenv('WP_MULTISITE'); |
|
| 51 | +$multisite = $multisite || (defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE); |
|
| 52 | +$multisite = $multisite || (defined('MULTISITE') && MULTISITE); |
|
| 53 | 53 | |
| 54 | 54 | // Override the PHPMailer |
| 55 | -require_once( dirname( __FILE__ ) . '/mock-mailer.php' ); |
|
| 56 | -$phpmailer = new MockPHPMailer( true ); |
|
| 55 | +require_once(dirname(__FILE__) . '/mock-mailer.php'); |
|
| 56 | +$phpmailer = new MockPHPMailer(true); |
|
| 57 | 57 | |
| 58 | -if ( ! defined( 'WP_DEFAULT_THEME' ) ) { |
|
| 59 | - define( 'WP_DEFAULT_THEME', 'default' ); |
|
| 58 | +if ( ! defined('WP_DEFAULT_THEME')) { |
|
| 59 | + define('WP_DEFAULT_THEME', 'default'); |
|
| 60 | 60 | } |
| 61 | -$wp_theme_directories = array( DIR_TESTDATA . '/themedir1' ); |
|
| 61 | +$wp_theme_directories = array(DIR_TESTDATA . '/themedir1'); |
|
| 62 | 62 | |
| 63 | -system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite ); |
|
| 63 | +system(WP_PHP_BINARY . ' ' . escapeshellarg(dirname(__FILE__) . '/install.php') . ' ' . escapeshellarg($config_file_path) . ' ' . $multisite); |
|
| 64 | 64 | |
| 65 | -if ( $multisite ) { |
|
| 65 | +if ($multisite) { |
|
| 66 | 66 | echo "Running as multisite..." . PHP_EOL; |
| 67 | - defined( 'MULTISITE' ) or define( 'MULTISITE', true ); |
|
| 68 | - defined( 'SUBDOMAIN_INSTALL' ) or define( 'SUBDOMAIN_INSTALL', false ); |
|
| 67 | + defined('MULTISITE') or define('MULTISITE', true); |
|
| 68 | + defined('SUBDOMAIN_INSTALL') or define('SUBDOMAIN_INSTALL', false); |
|
| 69 | 69 | $GLOBALS['base'] = '/'; |
| 70 | 70 | } else { |
| 71 | 71 | echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL; |
| 72 | 72 | } |
| 73 | -unset( $multisite ); |
|
| 73 | +unset($multisite); |
|
| 74 | 74 | |
| 75 | 75 | $GLOBALS['_wp_die_disabled'] = false; |
| 76 | 76 | // Allow tests to override wp_die |
| 77 | -tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' ); |
|
| 77 | +tests_add_filter('wp_die_handler', '_wp_die_handler_filter'); |
|
| 78 | 78 | |
| 79 | 79 | // Preset WordPress options defined in bootstrap file. |
| 80 | 80 | // Used to activate themes, plugins, as well as other settings. |
| 81 | -if(isset($GLOBALS['wp_tests_options'])) { |
|
| 82 | - function wp_tests_options( $value ) { |
|
| 83 | - $key = substr( current_filter(), strlen( 'pre_option_' ) ); |
|
| 81 | +if (isset($GLOBALS['wp_tests_options'])) { |
|
| 82 | + function wp_tests_options($value) { |
|
| 83 | + $key = substr(current_filter(), strlen('pre_option_')); |
|
| 84 | 84 | return $GLOBALS['wp_tests_options'][$key]; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - foreach ( array_keys( $GLOBALS['wp_tests_options'] ) as $key ) { |
|
| 88 | - tests_add_filter( 'pre_option_'.$key, 'wp_tests_options' ); |
|
| 87 | + foreach (array_keys($GLOBALS['wp_tests_options']) as $key) { |
|
| 88 | + tests_add_filter('pre_option_' . $key, 'wp_tests_options'); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | // Delete any default posts & related data |
| 96 | 96 | _delete_all_posts(); |
| 97 | 97 | |
| 98 | -require dirname( __FILE__ ) . '/testcase.php'; |
|
| 99 | -require dirname( __FILE__ ) . '/testcase-rest-api.php'; |
|
| 100 | -require dirname( __FILE__ ) . '/testcase-rest-controller.php'; |
|
| 101 | -require dirname( __FILE__ ) . '/testcase-rest-post-type-controller.php'; |
|
| 102 | -require dirname( __FILE__ ) . '/testcase-xmlrpc.php'; |
|
| 103 | -require dirname( __FILE__ ) . '/testcase-ajax.php'; |
|
| 104 | -require dirname( __FILE__ ) . '/testcase-canonical.php'; |
|
| 105 | -require dirname( __FILE__ ) . '/exceptions.php'; |
|
| 106 | -require dirname( __FILE__ ) . '/utils.php'; |
|
| 107 | -require dirname( __FILE__ ) . '/spy-rest-server.php'; |
|
| 98 | +require dirname(__FILE__) . '/testcase.php'; |
|
| 99 | +require dirname(__FILE__) . '/testcase-rest-api.php'; |
|
| 100 | +require dirname(__FILE__) . '/testcase-rest-controller.php'; |
|
| 101 | +require dirname(__FILE__) . '/testcase-rest-post-type-controller.php'; |
|
| 102 | +require dirname(__FILE__) . '/testcase-xmlrpc.php'; |
|
| 103 | +require dirname(__FILE__) . '/testcase-ajax.php'; |
|
| 104 | +require dirname(__FILE__) . '/testcase-canonical.php'; |
|
| 105 | +require dirname(__FILE__) . '/exceptions.php'; |
|
| 106 | +require dirname(__FILE__) . '/utils.php'; |
|
| 107 | +require dirname(__FILE__) . '/spy-rest-server.php'; |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * A child class of the PHP test runner. |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | 'exclude-group=', |
| 125 | 125 | 'group=', |
| 126 | 126 | ); |
| 127 | - function __construct( $argv ) { |
|
| 128 | - array_shift( $argv ); |
|
| 127 | + function __construct($argv) { |
|
| 128 | + array_shift($argv); |
|
| 129 | 129 | $options = array(); |
| 130 | - while ( list( $i, $arg ) = each( $argv ) ) { |
|
| 130 | + while (list($i, $arg) = each($argv)) { |
|
| 131 | 131 | try { |
| 132 | - if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { |
|
| 133 | - PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); |
|
| 132 | + if (strlen($arg) > 1 && $arg[0] === '-' && $arg[1] === '-') { |
|
| 133 | + PHPUnit_Util_Getopt::parseLongOption(substr($arg, 2), $this->longOptions, $options, $argv); |
|
| 134 | 134 | } |
| 135 | - } catch ( PHPUnit_Framework_Exception $e ) { |
|
| 135 | + } catch (PHPUnit_Framework_Exception $e) { |
|
| 136 | 136 | // Enforcing recognized arguments or correctly formed arguments is |
| 137 | 137 | // not really the concern here. |
| 138 | 138 | continue; |
@@ -145,36 +145,36 @@ discard block |
||
| 145 | 145 | 'external-http' => true, |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - foreach ( $options as $option ) { |
|
| 149 | - switch ( $option[0] ) { |
|
| 148 | + foreach ($options as $option) { |
|
| 149 | + switch ($option[0]) { |
|
| 150 | 150 | case '--exclude-group' : |
| 151 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 152 | - $skipped_groups[ $group_name ] = false; |
|
| 151 | + foreach ($skipped_groups as $group_name => $skipped) { |
|
| 152 | + $skipped_groups[$group_name] = false; |
|
| 153 | 153 | } |
| 154 | 154 | continue 2; |
| 155 | 155 | case '--group' : |
| 156 | - $groups = explode( ',', $option[1] ); |
|
| 157 | - foreach ( $groups as $group ) { |
|
| 158 | - if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) { |
|
| 159 | - WP_UnitTestCase::forceTicket( $group ); |
|
| 156 | + $groups = explode(',', $option[1]); |
|
| 157 | + foreach ($groups as $group) { |
|
| 158 | + if (is_numeric($group) || preg_match('/^(UT|Plugin)\d+$/', $group)) { |
|
| 159 | + WP_UnitTestCase::forceTicket($group); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 164 | - if ( in_array( $group_name, $groups ) ) { |
|
| 165 | - $skipped_groups[ $group_name ] = false; |
|
| 163 | + foreach ($skipped_groups as $group_name => $skipped) { |
|
| 164 | + if (in_array($group_name, $groups)) { |
|
| 165 | + $skipped_groups[$group_name] = false; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | continue 2; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $skipped_groups = array_filter( $skipped_groups ); |
|
| 173 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
| 174 | - echo sprintf( 'Not running %1$s tests. To execute these, use --group %1$s.', $group_name ) . PHP_EOL; |
|
| 172 | + $skipped_groups = array_filter($skipped_groups); |
|
| 173 | + foreach ($skipped_groups as $group_name => $skipped) { |
|
| 174 | + echo sprintf('Not running %1$s tests. To execute these, use --group %1$s.', $group_name) . PHP_EOL; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ( ! isset( $skipped_groups['external-http'] ) ) { |
|
| 177 | + if ( ! isset($skipped_groups['external-http'])) { |
|
| 178 | 178 | echo PHP_EOL; |
| 179 | 179 | echo 'External HTTP skipped tests can be caused by timeouts.' . PHP_EOL; |
| 180 | 180 | echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL; |
@@ -182,4 +182,4 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | -new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] ); |
|
| 185 | +new WP_PHPUnit_Util_Getopt($_SERVER['argv']); |
|
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // dummy theme |
| 4 | 4 | |
| 5 | -echo dirname(__FILE__).'/'.basename(__FILE__); |
|
| 5 | +echo dirname(__FILE__) . '/' . basename(__FILE__); |
|
| 6 | 6 | |
| 7 | 7 | ?> |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // dummy theme |
| 4 | 4 | |
| 5 | -echo dirname(__FILE__).'/'.basename(__FILE__); |
|
| 5 | +echo dirname(__FILE__) . '/' . basename(__FILE__); |
|
| 6 | 6 | |
| 7 | 7 | ?> |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // dummy theme |
| 4 | 4 | |
| 5 | -echo dirname(__FILE__).'/'.basename(__FILE__); |
|
| 5 | +echo dirname(__FILE__) . '/' . basename(__FILE__); |
|
| 6 | 6 | |
| 7 | 7 | ?> |