@@ -7,22 +7,22 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // don't load directly |
10 | -if ( !defined('ABSPATH') ) |
|
10 | +if ( ! defined('ABSPATH')) |
|
11 | 11 | die('-1'); |
12 | 12 | |
13 | -if ( ! empty($link_id) ) { |
|
14 | - $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' ); |
|
13 | +if ( ! empty($link_id)) { |
|
14 | + $heading = sprintf(__('<a href="%s">Links</a> / Edit Link'), 'link-manager.php'); |
|
15 | 15 | $submit_text = __('Update Link'); |
16 | 16 | $form_name = 'editlink'; |
17 | - $nonce_action = 'update-bookmark_' . $link_id; |
|
17 | + $nonce_action = 'update-bookmark_'.$link_id; |
|
18 | 18 | } else { |
19 | - $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' ); |
|
19 | + $heading = sprintf(__('<a href="%s">Links</a> / Add New Link'), 'link-manager.php'); |
|
20 | 20 | $submit_text = __('Add Link'); |
21 | 21 | $form_name = 'addlink'; |
22 | 22 | $nonce_action = 'add-bookmark'; |
23 | 23 | } |
24 | 24 | |
25 | -require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); |
|
25 | +require_once(ABSPATH.'wp-admin/includes/meta-boxes.php'); |
|
26 | 26 | |
27 | 27 | add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', null, 'side', 'core'); |
28 | 28 | add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', null, 'normal', 'core'); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', null, 'normal', 'core'); |
32 | 32 | |
33 | 33 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
34 | -do_action( 'add_meta_boxes', 'link', $link ); |
|
34 | +do_action('add_meta_boxes', 'link', $link); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Fires when link-specific meta boxes are added. |
@@ -40,51 +40,51 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param object $link Link object. |
42 | 42 | */ |
43 | -do_action( 'add_meta_boxes_link', $link ); |
|
43 | +do_action('add_meta_boxes_link', $link); |
|
44 | 44 | |
45 | 45 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
46 | -do_action( 'do_meta_boxes', 'link', 'normal', $link ); |
|
46 | +do_action('do_meta_boxes', 'link', 'normal', $link); |
|
47 | 47 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
48 | -do_action( 'do_meta_boxes', 'link', 'advanced', $link ); |
|
48 | +do_action('do_meta_boxes', 'link', 'advanced', $link); |
|
49 | 49 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
50 | -do_action( 'do_meta_boxes', 'link', 'side', $link ); |
|
50 | +do_action('do_meta_boxes', 'link', 'side', $link); |
|
51 | 51 | |
52 | -add_screen_option('layout_columns', array('max' => 2, 'default' => 2) ); |
|
52 | +add_screen_option('layout_columns', array('max' => 2, 'default' => 2)); |
|
53 | 53 | |
54 | -get_current_screen()->add_help_tab( array( |
|
54 | +get_current_screen()->add_help_tab(array( |
|
55 | 55 | 'id' => 'overview', |
56 | 56 | 'title' => __('Overview'), |
57 | 57 | 'content' => |
58 | - '<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' . |
|
59 | - '<p>' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' . |
|
60 | - '<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/" target="_blank">XHTML Friends Network</a>, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '</p>' |
|
61 | -) ); |
|
58 | + '<p>'.__('You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.').'</p>'. |
|
59 | + '<p>'.__('The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.').'</p>'. |
|
60 | + '<p>'.__('XFN stands for <a href="http://gmpg.org/xfn/" target="_blank">XHTML Friends Network</a>, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.').'</p>' |
|
61 | +)); |
|
62 | 62 | |
63 | 63 | get_current_screen()->set_help_sidebar( |
64 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
65 | - '<p>' . __( '<a href="https://codex.wordpress.org/Links_Add_New_Screen" target="_blank">Documentation on Creating Links</a>' ) . '</p>' . |
|
66 | - '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
|
64 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
65 | + '<p>'.__('<a href="https://codex.wordpress.org/Links_Add_New_Screen" target="_blank">Documentation on Creating Links</a>').'</p>'. |
|
66 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
67 | 67 | ); |
68 | 68 | |
69 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
69 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
70 | 70 | ?> |
71 | 71 | |
72 | 72 | <div class="wrap"> |
73 | -<h1><?php echo esc_html( $title ); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a></h1> |
|
73 | +<h1><?php echo esc_html($title); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a></h1> |
|
74 | 74 | |
75 | -<?php if ( isset( $_GET['added'] ) ) : ?> |
|
75 | +<?php if (isset($_GET['added'])) : ?> |
|
76 | 76 | <div id="message" class="updated notice is-dismissible"><p><?php _e('Link added.'); ?></p></div> |
77 | 77 | <?php endif; ?> |
78 | 78 | |
79 | -<form name="<?php echo esc_attr( $form_name ); ?>" id="<?php echo esc_attr( $form_name ); ?>" method="post" action="link.php"> |
|
79 | +<form name="<?php echo esc_attr($form_name); ?>" id="<?php echo esc_attr($form_name); ?>" method="post" action="link.php"> |
|
80 | 80 | <?php |
81 | -if ( ! empty( $link_added ) ) { |
|
81 | +if ( ! empty($link_added)) { |
|
82 | 82 | echo $link_added; |
83 | 83 | } |
84 | 84 | |
85 | -wp_nonce_field( $nonce_action ); |
|
86 | -wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
87 | -wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
85 | +wp_nonce_field($nonce_action); |
|
86 | +wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
87 | +wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
88 | 88 | |
89 | 89 | <div id="poststuff"> |
90 | 90 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | <?php |
120 | 120 | |
121 | 121 | /** This action is documented in wp-admin/includes/meta-boxes.php */ |
122 | -do_action( 'submitlink_box' ); |
|
123 | -$side_meta_boxes = do_meta_boxes( 'link', 'side', $link ); |
|
122 | +do_action('submitlink_box'); |
|
123 | +$side_meta_boxes = do_meta_boxes('link', 'side', $link); |
|
124 | 124 | |
125 | 125 | ?> |
126 | 126 | </div> |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | </div> |
136 | 136 | <?php |
137 | 137 | |
138 | -if ( $link_id ) : ?> |
|
138 | +if ($link_id) : ?> |
|
139 | 139 | <input type="hidden" name="action" value="save" /> |
140 | 140 | <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> |
141 | 141 | <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> |
@@ -7,8 +7,9 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // don't load directly |
10 | -if ( !defined('ABSPATH') ) |
|
10 | +if ( !defined('ABSPATH') ) { |
|
11 | 11 | die('-1'); |
12 | +} |
|
12 | 13 | |
13 | 14 | if ( ! empty($link_id) ) { |
14 | 15 | $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' ); |
@@ -139,9 +140,12 @@ discard block |
||
139 | 140 | <input type="hidden" name="action" value="save" /> |
140 | 141 | <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> |
141 | 142 | <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> |
142 | -<?php else: ?> |
|
143 | +<?php else { |
|
144 | + : ?> |
|
143 | 145 | <input type="hidden" name="action" value="add" /> |
144 | -<?php endif; ?> |
|
146 | +<?php endif; |
|
147 | +} |
|
148 | +?> |
|
145 | 149 | |
146 | 150 | </div> |
147 | 151 | </div> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @subpackage Administration |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined('ABSPATH') ) |
|
9 | +if ( ! defined('ABSPATH')) |
|
10 | 10 | die(); |
11 | 11 | |
12 | 12 | /** |
@@ -33,28 +33,28 @@ discard block |
||
33 | 33 | function startElement($parser, $tagName, $attrs) { |
34 | 34 | global $names, $urls, $targets, $descriptions, $feeds; |
35 | 35 | |
36 | - if ( 'OUTLINE' === $tagName ) { |
|
36 | + if ('OUTLINE' === $tagName) { |
|
37 | 37 | $name = ''; |
38 | - if ( isset( $attrs['TEXT'] ) ) { |
|
38 | + if (isset($attrs['TEXT'])) { |
|
39 | 39 | $name = $attrs['TEXT']; |
40 | 40 | } |
41 | - if ( isset( $attrs['TITLE'] ) ) { |
|
41 | + if (isset($attrs['TITLE'])) { |
|
42 | 42 | $name = $attrs['TITLE']; |
43 | 43 | } |
44 | 44 | $url = ''; |
45 | - if ( isset( $attrs['URL'] ) ) { |
|
45 | + if (isset($attrs['URL'])) { |
|
46 | 46 | $url = $attrs['URL']; |
47 | 47 | } |
48 | - if ( isset( $attrs['HTMLURL'] ) ) { |
|
48 | + if (isset($attrs['HTMLURL'])) { |
|
49 | 49 | $url = $attrs['HTMLURL']; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Save the data away. |
53 | 53 | $names[] = $name; |
54 | 54 | $urls[] = $url; |
55 | - $targets[] = isset( $attrs['TARGET'] ) ? $attrs['TARGET'] : ''; |
|
56 | - $feeds[] = isset( $attrs['XMLURL'] ) ? $attrs['XMLURL'] : ''; |
|
57 | - $descriptions[] = isset( $attrs['DESCRIPTION'] ) ? $attrs['DESCRIPTION'] : ''; |
|
55 | + $targets[] = isset($attrs['TARGET']) ? $attrs['TARGET'] : ''; |
|
56 | + $feeds[] = isset($attrs['XMLURL']) ? $attrs['XMLURL'] : ''; |
|
57 | + $descriptions[] = isset($attrs['DESCRIPTION']) ? $attrs['DESCRIPTION'] : ''; |
|
58 | 58 | } // End if outline. |
59 | 59 | } |
60 | 60 | |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | // Set the functions to handle opening and closing tags |
78 | 78 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
79 | 79 | |
80 | -if ( ! xml_parse( $xml_parser, $opml, true ) ) { |
|
80 | +if ( ! xml_parse($xml_parser, $opml, true)) { |
|
81 | 81 | printf( |
82 | 82 | /* translators: 1: error message, 2: line number */ |
83 | - __( 'XML Error: %1$s at line %2$s' ), |
|
84 | - xml_error_string( xml_get_error_code( $xml_parser ) ), |
|
85 | - xml_get_current_line_number( $xml_parser ) |
|
83 | + __('XML Error: %1$s at line %2$s'), |
|
84 | + xml_error_string(xml_get_error_code($xml_parser)), |
|
85 | + xml_get_current_line_number($xml_parser) |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @subpackage Administration |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined('ABSPATH') ) |
|
9 | +if ( ! defined('ABSPATH') ) { |
|
10 | 10 | die(); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * @global string $opml |
@@ -7,43 +7,43 @@ discard block |
||
7 | 7 | * @since 3.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( !is_multisite() ) |
|
13 | - wp_die( __( 'Multisite support is not enabled.' ) ); |
|
12 | +if ( ! is_multisite()) |
|
13 | + wp_die(__('Multisite support is not enabled.')); |
|
14 | 14 | |
15 | -if ( ! current_user_can( 'delete_site' ) ) |
|
16 | - wp_die(__( 'You do not have sufficient permissions to delete this site.')); |
|
15 | +if ( ! current_user_can('delete_site')) |
|
16 | + wp_die(__('You do not have sufficient permissions to delete this site.')); |
|
17 | 17 | |
18 | -if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { |
|
19 | - if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) { |
|
20 | - wpmu_delete_blog( $wpdb->blogid ); |
|
21 | - wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), $current_site->site_name ) ); |
|
18 | +if (isset($_GET['h']) && $_GET['h'] != '' && get_option('delete_blog_hash') != false) { |
|
19 | + if (get_option('delete_blog_hash') == $_GET['h']) { |
|
20 | + wpmu_delete_blog($wpdb->blogid); |
|
21 | + wp_die(sprintf(__('Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.'), $current_site->site_name)); |
|
22 | 22 | } else { |
23 | - wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) ); |
|
23 | + wp_die(__("I'm sorry, the link you clicked is stale. Please select another option.")); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | $blog = get_blog_details(); |
28 | 28 | $user = wp_get_current_user(); |
29 | 29 | |
30 | -$title = __( 'Delete Site' ); |
|
30 | +$title = __('Delete Site'); |
|
31 | 31 | $parent_file = 'tools.php'; |
32 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
32 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
33 | 33 | |
34 | 34 | echo '<div class="wrap">'; |
35 | -echo '<h1>' . esc_html( $title ) . '</h1>'; |
|
35 | +echo '<h1>'.esc_html($title).'</h1>'; |
|
36 | 36 | |
37 | -if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) { |
|
38 | - check_admin_referer( 'delete-blog' ); |
|
37 | +if (isset($_POST['action']) && $_POST['action'] == 'deleteblog' && isset($_POST['confirmdelete']) && $_POST['confirmdelete'] == '1') { |
|
38 | + check_admin_referer('delete-blog'); |
|
39 | 39 | |
40 | - $hash = wp_generate_password( 20, false ); |
|
41 | - update_option( 'delete_blog_hash', $hash ); |
|
40 | + $hash = wp_generate_password(20, false); |
|
41 | + update_option('delete_blog_hash', $hash); |
|
42 | 42 | |
43 | - $url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) ); |
|
43 | + $url_delete = esc_url(admin_url('ms-delete-site.php?h='.$hash)); |
|
44 | 44 | |
45 | 45 | /* translators: Do not translate USERNAME, URL_DELETE, SITE_NAME: those are placeholders. */ |
46 | - $content = __( "Howdy ###USERNAME###, |
|
46 | + $content = __("Howdy ###USERNAME###, |
|
47 | 47 | |
48 | 48 | You recently clicked the 'Delete Site' link on your site and filled in a |
49 | 49 | form on that page. |
@@ -66,30 +66,30 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network. |
68 | 68 | */ |
69 | - $content = apply_filters( 'delete_site_email_content', $content ); |
|
69 | + $content = apply_filters('delete_site_email_content', $content); |
|
70 | 70 | |
71 | - $content = str_replace( '###USERNAME###', $user->user_login, $content ); |
|
72 | - $content = str_replace( '###URL_DELETE###', $url_delete, $content ); |
|
73 | - $content = str_replace( '###SITE_NAME###', $current_site->site_name, $content ); |
|
71 | + $content = str_replace('###USERNAME###', $user->user_login, $content); |
|
72 | + $content = str_replace('###URL_DELETE###', $url_delete, $content); |
|
73 | + $content = str_replace('###SITE_NAME###', $current_site->site_name, $content); |
|
74 | 74 | |
75 | - wp_mail( get_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ] ".__( 'Delete My Site' ), $content ); |
|
75 | + wp_mail(get_option('admin_email'), "[ ".wp_specialchars_decode(get_option('blogname'))." ] ".__('Delete My Site'), $content); |
|
76 | 76 | ?> |
77 | 77 | |
78 | - <p><?php _e( 'Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked.' ) ?></p> |
|
78 | + <p><?php _e('Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked.') ?></p> |
|
79 | 79 | |
80 | 80 | <?php } else { |
81 | 81 | ?> |
82 | - <p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?></p> |
|
83 | - <p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p> |
|
82 | + <p><?php printf(__('If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?></p> |
|
83 | + <p><?php _e('Remember, once deleted your site cannot be restored.') ?></p> |
|
84 | 84 | |
85 | 85 | <form method="post" name="deletedirect"> |
86 | - <?php wp_nonce_field( 'delete-blog' ) ?> |
|
86 | + <?php wp_nonce_field('delete-blog') ?> |
|
87 | 87 | <input type="hidden" name="action" value="deleteblog" /> |
88 | - <p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $blog->domain : $blog->domain . $blog->path ); ?></strong></label></p> |
|
89 | - <?php submit_button( __( 'Delete My Site Permanently' ) ); ?> |
|
88 | + <p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf(__("I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again."), is_subdomain_install() ? $blog->domain : $blog->domain.$blog->path); ?></strong></label></p> |
|
89 | + <?php submit_button(__('Delete My Site Permanently')); ?> |
|
90 | 90 | </form> |
91 | 91 | <?php |
92 | 92 | } |
93 | 93 | echo '</div>'; |
94 | 94 | |
95 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
95 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -9,11 +9,13 @@ |
||
9 | 9 | |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( !is_multisite() ) |
|
12 | +if ( !is_multisite() ) { |
|
13 | 13 | wp_die( __( 'Multisite support is not enabled.' ) ); |
14 | +} |
|
14 | 15 | |
15 | -if ( ! current_user_can( 'delete_site' ) ) |
|
16 | +if ( ! current_user_can( 'delete_site' ) ) { |
|
16 | 17 | wp_die(__( 'You do not have sufficient permissions to delete this site.')); |
18 | +} |
|
17 | 19 | |
18 | 20 | if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { |
19 | 21 | if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) { |
@@ -45,14 +45,14 @@ |
||
45 | 45 | 'title' => __('Overview'), |
46 | 46 | 'content' => |
47 | 47 | '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' . |
48 | - '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' . |
|
49 | - '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' |
|
48 | + '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' . |
|
49 | + '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' |
|
50 | 50 | ) ); |
51 | 51 | get_current_screen()->add_help_tab( array( |
52 | 52 | 'id' => 'deleting-links', |
53 | 53 | 'title' => __('Deleting Links'), |
54 | 54 | 'content' => |
55 | - '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' |
|
55 | + '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' |
|
56 | 56 | ) ); |
57 | 57 | |
58 | 58 | get_current_screen()->set_help_sidebar( |
@@ -7,31 +7,31 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** Load WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 | -if ( ! current_user_can( 'manage_links' ) ) |
|
12 | - wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | +if ( ! current_user_can('manage_links')) |
|
12 | + wp_die(__('You do not have sufficient permissions to edit the links for this site.')); |
|
13 | 13 | |
14 | 14 | $wp_list_table = _get_list_table('WP_Links_List_Table'); |
15 | 15 | |
16 | 16 | // Handle bulk deletes |
17 | 17 | $doaction = $wp_list_table->current_action(); |
18 | 18 | |
19 | -if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { |
|
20 | - check_admin_referer( 'bulk-bookmarks' ); |
|
19 | +if ($doaction && isset($_REQUEST['linkcheck'])) { |
|
20 | + check_admin_referer('bulk-bookmarks'); |
|
21 | 21 | |
22 | - if ( 'delete' == $doaction ) { |
|
22 | + if ('delete' == $doaction) { |
|
23 | 23 | $bulklinks = (array) $_REQUEST['linkcheck']; |
24 | - foreach ( $bulklinks as $link_id ) { |
|
24 | + foreach ($bulklinks as $link_id) { |
|
25 | 25 | $link_id = (int) $link_id; |
26 | 26 | |
27 | - wp_delete_link( $link_id ); |
|
27 | + wp_delete_link($link_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) ); |
|
30 | + wp_redirect(add_query_arg('deleted', count($bulklinks), admin_url('link-manager.php'))); |
|
31 | 31 | exit; |
32 | 32 | } |
33 | -} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
|
34 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
33 | +} elseif ( ! empty($_GET['_wp_http_referer'])) { |
|
34 | + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); |
|
35 | 35 | exit; |
36 | 36 | } |
37 | 37 | |
@@ -40,42 +40,42 @@ discard block |
||
40 | 40 | $title = __('Links'); |
41 | 41 | $this_file = $parent_file = 'link-manager.php'; |
42 | 42 | |
43 | -get_current_screen()->add_help_tab( array( |
|
43 | +get_current_screen()->add_help_tab(array( |
|
44 | 44 | 'id' => 'overview', |
45 | 45 | 'title' => __('Overview'), |
46 | 46 | 'content' => |
47 | - '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' . |
|
48 | - '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' . |
|
49 | - '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' |
|
50 | -) ); |
|
51 | -get_current_screen()->add_help_tab( array( |
|
47 | + '<p>'.sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php').'</p>'. |
|
48 | + '<p>'.__('Links may be separated into Link Categories; these are different than the categories used on your posts.').'</p>'. |
|
49 | + '<p>'.__('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.').'</p>' |
|
50 | +)); |
|
51 | +get_current_screen()->add_help_tab(array( |
|
52 | 52 | 'id' => 'deleting-links', |
53 | 53 | 'title' => __('Deleting Links'), |
54 | 54 | 'content' => |
55 | - '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' |
|
56 | -) ); |
|
55 | + '<p>'.__('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.').'</p>' |
|
56 | +)); |
|
57 | 57 | |
58 | 58 | get_current_screen()->set_help_sidebar( |
59 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
60 | - '<p>' . __('<a href="https://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>') . '</p>' . |
|
61 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
59 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
60 | + '<p>'.__('<a href="https://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>').'</p>'. |
|
61 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
62 | 62 | ); |
63 | 63 | |
64 | -include_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
64 | +include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
65 | 65 | |
66 | -if ( ! current_user_can('manage_links') ) |
|
66 | +if ( ! current_user_can('manage_links')) |
|
67 | 67 | wp_die(__("You do not have sufficient permissions to edit the links for this site.")); |
68 | 68 | |
69 | 69 | ?> |
70 | 70 | |
71 | 71 | <div class="wrap nosubsub"> |
72 | -<h1><?php echo esc_html( $title ); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php |
|
73 | -if ( !empty($_REQUEST['s']) ) |
|
74 | - printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?> |
|
72 | +<h1><?php echo esc_html($title); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php |
|
73 | +if ( ! empty($_REQUEST['s'])) |
|
74 | + printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', esc_html(wp_unslash($_REQUEST['s']))); ?> |
|
75 | 75 | </h1> |
76 | 76 | |
77 | 77 | <?php |
78 | -if ( isset($_REQUEST['deleted']) ) { |
|
78 | +if (isset($_REQUEST['deleted'])) { |
|
79 | 79 | echo '<div id="message" class="updated notice is-dismissible"><p>'; |
80 | 80 | $deleted = (int) $_REQUEST['deleted']; |
81 | 81 | printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | <form id="posts-filter" method="get"> |
88 | 88 | |
89 | -<?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?> |
|
89 | +<?php $wp_list_table->search_box(__('Search Links'), 'link'); ?> |
|
90 | 90 | |
91 | 91 | <?php $wp_list_table->display(); ?> |
92 | 92 | |
@@ -96,4 +96,4 @@ discard block |
||
96 | 96 | </div> |
97 | 97 | |
98 | 98 | <?php |
99 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
99 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -8,8 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | /** Load WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | -if ( ! current_user_can( 'manage_links' ) ) |
|
11 | +if ( ! current_user_can( 'manage_links' ) ) { |
|
12 | 12 | wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) ); |
13 | +} |
|
13 | 14 | |
14 | 15 | $wp_list_table = _get_list_table('WP_Links_List_Table'); |
15 | 16 | |
@@ -63,15 +64,18 @@ discard block |
||
63 | 64 | |
64 | 65 | include_once( ABSPATH . 'wp-admin/admin-header.php' ); |
65 | 66 | |
66 | -if ( ! current_user_can('manage_links') ) |
|
67 | +if ( ! current_user_can('manage_links') ) { |
|
67 | 68 | wp_die(__("You do not have sufficient permissions to edit the links for this site.")); |
69 | +} |
|
68 | 70 | |
69 | 71 | ?> |
70 | 72 | |
71 | 73 | <div class="wrap nosubsub"> |
72 | 74 | <h1><?php echo esc_html( $title ); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php |
73 | -if ( !empty($_REQUEST['s']) ) |
|
74 | - printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?> |
|
75 | +if ( !empty($_REQUEST['s']) ) { |
|
76 | + printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); |
|
77 | +} |
|
78 | +?> |
|
75 | 79 | </h1> |
76 | 80 | |
77 | 81 | <?php |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * New User Administration Screen. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * New User Administration Screen. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | ) ); |
185 | 185 | |
186 | 186 | get_current_screen()->set_help_sidebar( |
187 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
188 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Add_New_Screen" target="_blank">Documentation on Adding New Users</a>') . '</p>' . |
|
189 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
187 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
188 | + '<p>' . __('<a href="https://codex.wordpress.org/Users_Add_New_Screen" target="_blank">Documentation on Adding New Users</a>') . '</p>' . |
|
189 | + '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
190 | 190 | ); |
191 | 191 | |
192 | 192 | wp_enqueue_script('wp-ajax-response'); |
@@ -317,16 +317,16 @@ discard block |
||
317 | 317 | </table> |
318 | 318 | <?php |
319 | 319 | /** |
320 | - * Fires at the end of the new user form. |
|
321 | - * |
|
322 | - * Passes a contextual string to make both types of new user forms |
|
323 | - * uniquely targetable. Contexts are 'add-existing-user' (Multisite), |
|
324 | - * and 'add-new-user' (single site and network admin). |
|
325 | - * |
|
326 | - * @since 3.7.0 |
|
327 | - * |
|
328 | - * @param string $type A contextual string specifying which type of new user form the hook follows. |
|
329 | - */ |
|
320 | + * Fires at the end of the new user form. |
|
321 | + * |
|
322 | + * Passes a contextual string to make both types of new user forms |
|
323 | + * uniquely targetable. Contexts are 'add-existing-user' (Multisite), |
|
324 | + * and 'add-new-user' (single site and network admin). |
|
325 | + * |
|
326 | + * @since 3.7.0 |
|
327 | + * |
|
328 | + * @param string $type A contextual string specifying which type of new user form the hook follows. |
|
329 | + */ |
|
330 | 330 | do_action( 'user_new_form', 'add-existing-user' ); |
331 | 331 | ?> |
332 | 332 | <?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?> |
@@ -7,117 +7,117 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( is_multisite() ) { |
|
13 | - if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) |
|
14 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
15 | -} elseif ( ! current_user_can( 'create_users' ) ) { |
|
16 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
12 | +if (is_multisite()) { |
|
13 | + if ( ! current_user_can('create_users') && ! current_user_can('promote_users')) |
|
14 | + wp_die(__('Cheatin’ uh?'), 403); |
|
15 | +} elseif ( ! current_user_can('create_users')) { |
|
16 | + wp_die(__('Cheatin’ uh?'), 403); |
|
17 | 17 | } |
18 | 18 | |
19 | -if ( is_multisite() ) { |
|
19 | +if (is_multisite()) { |
|
20 | 20 | /** |
21 | 21 | * |
22 | 22 | * @param string $text |
23 | 23 | * @return string |
24 | 24 | */ |
25 | - function admin_created_user_email( $text ) { |
|
25 | + function admin_created_user_email($text) { |
|
26 | 26 | $roles = get_editable_roles(); |
27 | - $role = $roles[ $_REQUEST['role'] ]; |
|
27 | + $role = $roles[$_REQUEST['role']]; |
|
28 | 28 | /* translators: 1: Site name, 2: site URL, 3: role */ |
29 | - return sprintf( __( 'Hi, |
|
29 | + return sprintf(__('Hi, |
|
30 | 30 | You\'ve been invited to join \'%1$s\' at |
31 | 31 | %2$s with the role of %3$s. |
32 | 32 | If you do not want to join this site please ignore |
33 | 33 | this email. This invitation will expire in a few days. |
34 | 34 | |
35 | 35 | Please click the following link to activate your user account: |
36 | -%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) ); |
|
36 | +%%s' ), get_bloginfo('name'), home_url(), wp_specialchars_decode(translate_user_role($role['name']))); |
|
37 | 37 | } |
38 | - add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' ); |
|
38 | + add_filter('wpmu_signup_user_notification_email', 'admin_created_user_email'); |
|
39 | 39 | } |
40 | 40 | |
41 | -if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { |
|
42 | - check_admin_referer( 'add-user', '_wpnonce_add-user' ); |
|
41 | +if (isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action']) { |
|
42 | + check_admin_referer('add-user', '_wpnonce_add-user'); |
|
43 | 43 | |
44 | 44 | $user_details = null; |
45 | - $user_email = wp_unslash( $_REQUEST['email'] ); |
|
46 | - if ( false !== strpos( $user_email, '@' ) ) { |
|
47 | - $user_details = get_user_by( 'email', $user_email ); |
|
45 | + $user_email = wp_unslash($_REQUEST['email']); |
|
46 | + if (false !== strpos($user_email, '@')) { |
|
47 | + $user_details = get_user_by('email', $user_email); |
|
48 | 48 | } else { |
49 | - if ( is_super_admin() ) { |
|
50 | - $user_details = get_user_by( 'login', $user_email ); |
|
49 | + if (is_super_admin()) { |
|
50 | + $user_details = get_user_by('login', $user_email); |
|
51 | 51 | } else { |
52 | - wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); |
|
52 | + wp_redirect(add_query_arg(array('update' => 'enter_email'), 'user-new.php')); |
|
53 | 53 | die(); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - if ( !$user_details ) { |
|
58 | - wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) ); |
|
57 | + if ( ! $user_details) { |
|
58 | + wp_redirect(add_query_arg(array('update' => 'does_not_exist'), 'user-new.php')); |
|
59 | 59 | die(); |
60 | 60 | } |
61 | 61 | |
62 | - if ( ! current_user_can('promote_user', $user_details->ID) ) |
|
63 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
62 | + if ( ! current_user_can('promote_user', $user_details->ID)) |
|
63 | + wp_die(__('Cheatin’ uh?'), 403); |
|
64 | 64 | |
65 | 65 | // Adding an existing user to this blog |
66 | 66 | $new_user_email = $user_details->user_email; |
67 | 67 | $redirect = 'user-new.php'; |
68 | 68 | $username = $user_details->user_login; |
69 | 69 | $user_id = $user_details->ID; |
70 | - if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { |
|
71 | - $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); |
|
70 | + if (($username != null && ! is_super_admin($user_id)) && (array_key_exists($blog_id, get_blogs_of_user($user_id)))) { |
|
71 | + $redirect = add_query_arg(array('update' => 'addexisting'), 'user-new.php'); |
|
72 | 72 | } else { |
73 | - if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { |
|
74 | - add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); |
|
75 | - $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); |
|
73 | + if (isset($_POST['noconfirmation']) && is_super_admin()) { |
|
74 | + add_existing_user_to_blog(array('user_id' => $user_id, 'role' => $_REQUEST['role'])); |
|
75 | + $redirect = add_query_arg(array('update' => 'addnoconfirmation'), 'user-new.php'); |
|
76 | 76 | } else { |
77 | - $newuser_key = substr( md5( $user_id ), 0, 5 ); |
|
78 | - add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); |
|
77 | + $newuser_key = substr(md5($user_id), 0, 5); |
|
78 | + add_option('new_user_'.$newuser_key, array('user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST['role'])); |
|
79 | 79 | |
80 | 80 | $roles = get_editable_roles(); |
81 | - $role = $roles[ $_REQUEST['role'] ]; |
|
81 | + $role = $roles[$_REQUEST['role']]; |
|
82 | 82 | /* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */ |
83 | - $message = __( 'Hi, |
|
83 | + $message = __('Hi, |
|
84 | 84 | |
85 | 85 | You\'ve been invited to join \'%1$s\' at |
86 | 86 | %2$s with the role of %3$s. |
87 | 87 | |
88 | 88 | Please click the following link to confirm the invite: |
89 | 89 | %4$s' ); |
90 | - wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ), home_url( "/newbloguser/$newuser_key/" ) ) ); |
|
91 | - $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); |
|
90 | + wp_mail($new_user_email, sprintf(__('[%s] Joining confirmation'), wp_specialchars_decode(get_option('blogname'))), sprintf($message, get_option('blogname'), home_url(), wp_specialchars_decode(translate_user_role($role['name'])), home_url("/newbloguser/$newuser_key/"))); |
|
91 | + $redirect = add_query_arg(array('update' => 'add'), 'user-new.php'); |
|
92 | 92 | } |
93 | 93 | } |
94 | - wp_redirect( $redirect ); |
|
94 | + wp_redirect($redirect); |
|
95 | 95 | die(); |
96 | -} elseif ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) { |
|
97 | - check_admin_referer( 'create-user', '_wpnonce_create-user' ); |
|
96 | +} elseif (isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action']) { |
|
97 | + check_admin_referer('create-user', '_wpnonce_create-user'); |
|
98 | 98 | |
99 | - if ( ! current_user_can('create_users') ) |
|
100 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
99 | + if ( ! current_user_can('create_users')) |
|
100 | + wp_die(__('Cheatin’ uh?'), 403); |
|
101 | 101 | |
102 | - if ( ! is_multisite() ) { |
|
102 | + if ( ! is_multisite()) { |
|
103 | 103 | $user_id = edit_user(); |
104 | 104 | |
105 | - if ( is_wp_error( $user_id ) ) { |
|
105 | + if (is_wp_error($user_id)) { |
|
106 | 106 | $add_user_errors = $user_id; |
107 | 107 | } else { |
108 | - if ( current_user_can( 'list_users' ) ) |
|
109 | - $redirect = 'users.php?update=add&id=' . $user_id; |
|
108 | + if (current_user_can('list_users')) |
|
109 | + $redirect = 'users.php?update=add&id='.$user_id; |
|
110 | 110 | else |
111 | - $redirect = add_query_arg( 'update', 'add', 'user-new.php' ); |
|
112 | - wp_redirect( $redirect ); |
|
111 | + $redirect = add_query_arg('update', 'add', 'user-new.php'); |
|
112 | + wp_redirect($redirect); |
|
113 | 113 | die(); |
114 | 114 | } |
115 | 115 | } else { |
116 | 116 | // Adding a new user to this site |
117 | - $new_user_email = wp_unslash( $_REQUEST['email'] ); |
|
118 | - $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email ); |
|
119 | - if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) { |
|
120 | - $add_user_errors = $user_details[ 'errors' ]; |
|
117 | + $new_user_email = wp_unslash($_REQUEST['email']); |
|
118 | + $user_details = wpmu_validate_user_signup($_REQUEST['user_login'], $new_user_email); |
|
119 | + if (is_wp_error($user_details['errors']) && ! empty($user_details['errors']->errors)) { |
|
120 | + $add_user_errors = $user_details['errors']; |
|
121 | 121 | } else { |
122 | 122 | /** |
123 | 123 | * Filter the user_login, also known as the username, before it is added to the site. |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param string $user_login The sanitized username. |
128 | 128 | */ |
129 | - $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) ); |
|
130 | - if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { |
|
131 | - add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email |
|
132 | - add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email |
|
129 | + $new_user_login = apply_filters('pre_user_login', sanitize_user(wp_unslash($_REQUEST['user_login']), true)); |
|
130 | + if (isset($_POST['noconfirmation']) && is_super_admin()) { |
|
131 | + add_filter('wpmu_signup_user_notification', '__return_false'); // Disable confirmation email |
|
132 | + add_filter('wpmu_welcome_user_notification', '__return_false'); // Disable welcome email |
|
133 | 133 | } |
134 | - wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'] ) ); |
|
135 | - if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { |
|
136 | - $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) ); |
|
137 | - wpmu_activate_signup( $key ); |
|
138 | - $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); |
|
134 | + wpmu_signup_user($new_user_login, $new_user_email, array('add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'])); |
|
135 | + if (isset($_POST['noconfirmation']) && is_super_admin()) { |
|
136 | + $key = $wpdb->get_var($wpdb->prepare("SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email)); |
|
137 | + wpmu_activate_signup($key); |
|
138 | + $redirect = add_query_arg(array('update' => 'addnoconfirmation'), 'user-new.php'); |
|
139 | 139 | } else { |
140 | - $redirect = add_query_arg( array('update' => 'newuserconfirmation'), 'user-new.php' ); |
|
140 | + $redirect = add_query_arg(array('update' => 'newuserconfirmation'), 'user-new.php'); |
|
141 | 141 | } |
142 | - wp_redirect( $redirect ); |
|
142 | + wp_redirect($redirect); |
|
143 | 143 | die(); |
144 | 144 | } |
145 | 145 | } |
@@ -149,48 +149,48 @@ discard block |
||
149 | 149 | $parent_file = 'users.php'; |
150 | 150 | |
151 | 151 | $do_both = false; |
152 | -if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') ) |
|
152 | +if (is_multisite() && current_user_can('promote_users') && current_user_can('create_users')) |
|
153 | 153 | $do_both = true; |
154 | 154 | |
155 | -$help = '<p>' . __('To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.') . '</p>'; |
|
155 | +$help = '<p>'.__('To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.').'</p>'; |
|
156 | 156 | |
157 | -if ( is_multisite() ) { |
|
158 | - $help .= '<p>' . __('Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user’s name to Edit the user profile under Network Admin > All Users.') . '</p>' . |
|
159 | - '<p>' . __('New users will receive an email letting them know they’ve been added as a user for your site. This email will also contain their password. Check the box if you don’t want the user to receive a welcome email.') . '</p>'; |
|
157 | +if (is_multisite()) { |
|
158 | + $help .= '<p>'.__('Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user’s name to Edit the user profile under Network Admin > All Users.').'</p>'. |
|
159 | + '<p>'.__('New users will receive an email letting them know they’ve been added as a user for your site. This email will also contain their password. Check the box if you don’t want the user to receive a welcome email.').'</p>'; |
|
160 | 160 | } else { |
161 | - $help .= '<p>' . __('You must assign a password to the new user, which they can change after logging in. The username, however, cannot be changed.') . '</p>' . |
|
162 | - '<p>' . __('New users will receive an email letting them know they’ve been added as a user for your site. By default, this email will also contain their password. Uncheck the box if you don’t want the password to be included in the welcome email.') . '</p>'; |
|
161 | + $help .= '<p>'.__('You must assign a password to the new user, which they can change after logging in. The username, however, cannot be changed.').'</p>'. |
|
162 | + '<p>'.__('New users will receive an email letting them know they’ve been added as a user for your site. By default, this email will also contain their password. Uncheck the box if you don’t want the password to be included in the welcome email.').'</p>'; |
|
163 | 163 | } |
164 | 164 | |
165 | -$help .= '<p>' . __('Remember to click the Add New User button at the bottom of this screen when you are finished.') . '</p>'; |
|
165 | +$help .= '<p>'.__('Remember to click the Add New User button at the bottom of this screen when you are finished.').'</p>'; |
|
166 | 166 | |
167 | -get_current_screen()->add_help_tab( array( |
|
167 | +get_current_screen()->add_help_tab(array( |
|
168 | 168 | 'id' => 'overview', |
169 | 169 | 'title' => __('Overview'), |
170 | 170 | 'content' => $help, |
171 | -) ); |
|
171 | +)); |
|
172 | 172 | |
173 | -get_current_screen()->add_help_tab( array( |
|
173 | +get_current_screen()->add_help_tab(array( |
|
174 | 174 | 'id' => 'user-roles', |
175 | 175 | 'title' => __('User Roles'), |
176 | -'content' => '<p>' . __('Here is a basic overview of the different user roles and the permissions associated with each one:') . '</p>' . |
|
177 | - '<ul>' . |
|
178 | - '<li>' . __('Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.') . '</li>' . |
|
179 | - '<li>' . __('Contributors can write and manage their posts but not publish posts or upload media files.') . '</li>' . |
|
180 | - '<li>' . __('Authors can publish and manage their own posts, and are able to upload files.') . '</li>' . |
|
181 | - '<li>' . __('Editors can publish posts, manage posts as well as manage other people’s posts, etc.') . '</li>' . |
|
182 | - '<li>' . __('Administrators have access to all the administration features.') . '</li>' . |
|
176 | +'content' => '<p>'.__('Here is a basic overview of the different user roles and the permissions associated with each one:').'</p>'. |
|
177 | + '<ul>'. |
|
178 | + '<li>'.__('Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.').'</li>'. |
|
179 | + '<li>'.__('Contributors can write and manage their posts but not publish posts or upload media files.').'</li>'. |
|
180 | + '<li>'.__('Authors can publish and manage their own posts, and are able to upload files.').'</li>'. |
|
181 | + '<li>'.__('Editors can publish posts, manage posts as well as manage other people’s posts, etc.').'</li>'. |
|
182 | + '<li>'.__('Administrators have access to all the administration features.').'</li>'. |
|
183 | 183 | '</ul>' |
184 | -) ); |
|
184 | +)); |
|
185 | 185 | |
186 | 186 | get_current_screen()->set_help_sidebar( |
187 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
188 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Add_New_Screen" target="_blank">Documentation on Adding New Users</a>') . '</p>' . |
|
189 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
187 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
188 | + '<p>'.__('<a href="https://codex.wordpress.org/Users_Add_New_Screen" target="_blank">Documentation on Adding New Users</a>').'</p>'. |
|
189 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
190 | 190 | ); |
191 | 191 | |
192 | 192 | wp_enqueue_script('wp-ajax-response'); |
193 | -wp_enqueue_script( 'user-profile' ); |
|
193 | +wp_enqueue_script('user-profile'); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Filter whether to enable user auto-complete for non-super admins in Multisite. |
@@ -199,18 +199,18 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @param bool $enable Whether to enable auto-complete for non-super admins. Default false. |
201 | 201 | */ |
202 | -if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' ) |
|
203 | - && ( is_super_admin() || apply_filters( 'autocomplete_users_for_site_admins', false ) ) |
|
202 | +if (is_multisite() && current_user_can('promote_users') && ! wp_is_large_network('users') |
|
203 | + && (is_super_admin() || apply_filters('autocomplete_users_for_site_admins', false)) |
|
204 | 204 | ) { |
205 | - wp_enqueue_script( 'user-suggest' ); |
|
205 | + wp_enqueue_script('user-suggest'); |
|
206 | 206 | } |
207 | 207 | |
208 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
208 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
209 | 209 | |
210 | -if ( isset($_GET['update']) ) { |
|
210 | +if (isset($_GET['update'])) { |
|
211 | 211 | $messages = array(); |
212 | - if ( is_multisite() ) { |
|
213 | - switch ( $_GET['update'] ) { |
|
212 | + if (is_multisite()) { |
|
213 | + switch ($_GET['update']) { |
|
214 | 214 | case "newuserconfirmation": |
215 | 215 | $messages[] = __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.'); |
216 | 216 | break; |
@@ -231,40 +231,40 @@ discard block |
||
231 | 231 | break; |
232 | 232 | } |
233 | 233 | } else { |
234 | - if ( 'add' == $_GET['update'] ) |
|
234 | + if ('add' == $_GET['update']) |
|
235 | 235 | $messages[] = __('User added.'); |
236 | 236 | } |
237 | 237 | } |
238 | 238 | ?> |
239 | 239 | <div class="wrap"> |
240 | 240 | <h1 id="add-new-user"><?php |
241 | -if ( current_user_can( 'create_users' ) ) { |
|
242 | - echo _x( 'Add New User', 'user' ); |
|
243 | -} elseif ( current_user_can( 'promote_users' ) ) { |
|
244 | - echo _x( 'Add Existing User', 'user' ); |
|
241 | +if (current_user_can('create_users')) { |
|
242 | + echo _x('Add New User', 'user'); |
|
243 | +} elseif (current_user_can('promote_users')) { |
|
244 | + echo _x('Add Existing User', 'user'); |
|
245 | 245 | } ?> |
246 | 246 | </h1> |
247 | 247 | |
248 | -<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?> |
|
248 | +<?php if (isset($errors) && is_wp_error($errors)) : ?> |
|
249 | 249 | <div class="error"> |
250 | 250 | <ul> |
251 | 251 | <?php |
252 | - foreach ( $errors->get_error_messages() as $err ) |
|
252 | + foreach ($errors->get_error_messages() as $err) |
|
253 | 253 | echo "<li>$err</li>\n"; |
254 | 254 | ?> |
255 | 255 | </ul> |
256 | 256 | </div> |
257 | 257 | <?php endif; |
258 | 258 | |
259 | -if ( ! empty( $messages ) ) { |
|
260 | - foreach ( $messages as $msg ) |
|
261 | - echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
259 | +if ( ! empty($messages)) { |
|
260 | + foreach ($messages as $msg) |
|
261 | + echo '<div id="message" class="updated notice is-dismissible"><p>'.$msg.'</p></div>'; |
|
262 | 262 | } ?> |
263 | 263 | |
264 | -<?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?> |
|
264 | +<?php if (isset($add_user_errors) && is_wp_error($add_user_errors)) : ?> |
|
265 | 265 | <div class="error"> |
266 | 266 | <?php |
267 | - foreach ( $add_user_errors->get_error_messages() as $message ) |
|
267 | + foreach ($add_user_errors->get_error_messages() as $message) |
|
268 | 268 | echo "<p>$message</p>"; |
269 | 269 | ?> |
270 | 270 | </div> |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | <div id="ajax-response"></div> |
273 | 273 | |
274 | 274 | <?php |
275 | -if ( is_multisite() ) { |
|
276 | - if ( $do_both ) |
|
277 | - echo '<h3 id="add-existing-user">' . __('Add Existing User') . '</h3>'; |
|
278 | - if ( !is_super_admin() ) { |
|
279 | - echo '<p>' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
|
275 | +if (is_multisite()) { |
|
276 | + if ($do_both) |
|
277 | + echo '<h3 id="add-existing-user">'.__('Add Existing User').'</h3>'; |
|
278 | + if ( ! is_super_admin()) { |
|
279 | + echo '<p>'.__('Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.').'</p>'; |
|
280 | 280 | $label = __('E-mail'); |
281 | 281 | $type = 'email'; |
282 | 282 | } else { |
283 | - echo '<p>' . __( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
|
283 | + echo '<p>'.__('Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.').'</p>'; |
|
284 | 284 | $label = __('E-mail or Username'); |
285 | 285 | $type = 'text'; |
286 | 286 | } |
@@ -291,10 +291,10 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @since 3.0.0 |
293 | 293 | */ |
294 | - do_action( 'user_new_form_tag' ); |
|
294 | + do_action('user_new_form_tag'); |
|
295 | 295 | ?>> |
296 | 296 | <input name="action" type="hidden" value="adduser" /> |
297 | -<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?> |
|
297 | +<?php wp_nonce_field('add-user', '_wpnonce_add-user') ?> |
|
298 | 298 | |
299 | 299 | <table class="form-table"> |
300 | 300 | <tr class="form-field form-required"> |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | <tr class="form-field"> |
305 | 305 | <th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th> |
306 | 306 | <td><select name="role" id="adduser-role"> |
307 | - <?php wp_dropdown_roles( get_option('default_role') ); ?> |
|
307 | + <?php wp_dropdown_roles(get_option('default_role')); ?> |
|
308 | 308 | </select> |
309 | 309 | </td> |
310 | 310 | </tr> |
311 | -<?php if ( is_super_admin() ) { ?> |
|
311 | +<?php if (is_super_admin()) { ?> |
|
312 | 312 | <tr> |
313 | 313 | <th scope="row"><label for="adduser-noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th> |
314 | - <td><label for="adduser-noconfirmation"><input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> <?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label></td> |
|
314 | + <td><label for="adduser-noconfirmation"><input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> <?php _e('Add the user without sending an email that requires their confirmation.'); ?></label></td> |
|
315 | 315 | </tr> |
316 | 316 | <?php } ?> |
317 | 317 | </table> |
@@ -327,48 +327,48 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @param string $type A contextual string specifying which type of new user form the hook follows. |
329 | 329 | */ |
330 | -do_action( 'user_new_form', 'add-existing-user' ); |
|
330 | +do_action('user_new_form', 'add-existing-user'); |
|
331 | 331 | ?> |
332 | -<?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?> |
|
332 | +<?php submit_button(__('Add Existing User'), 'primary', 'adduser', true, array('id' => 'addusersub')); ?> |
|
333 | 333 | </form> |
334 | 334 | <?php |
335 | 335 | } // is_multisite() |
336 | 336 | |
337 | -if ( current_user_can( 'create_users') ) { |
|
338 | - if ( $do_both ) |
|
339 | - echo '<h3 id="create-new-user">' . __( 'Add New User' ) . '</h3>'; |
|
337 | +if (current_user_can('create_users')) { |
|
338 | + if ($do_both) |
|
339 | + echo '<h3 id="create-new-user">'.__('Add New User').'</h3>'; |
|
340 | 340 | ?> |
341 | 341 | <p><?php _e('Create a brand new user and add them to this site.'); ?></p> |
342 | 342 | <form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"<?php |
343 | 343 | /** This action is documented in wp-admin/user-new.php */ |
344 | - do_action( 'user_new_form_tag' ); |
|
344 | + do_action('user_new_form_tag'); |
|
345 | 345 | ?>> |
346 | 346 | <input name="action" type="hidden" value="createuser" /> |
347 | -<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?> |
|
347 | +<?php wp_nonce_field('create-user', '_wpnonce_create-user'); ?> |
|
348 | 348 | <?php |
349 | 349 | // Load up the passed data, else set to a default. |
350 | -$creating = isset( $_POST['createuser'] ); |
|
350 | +$creating = isset($_POST['createuser']); |
|
351 | 351 | |
352 | -$new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : ''; |
|
353 | -$new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : ''; |
|
354 | -$new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : ''; |
|
355 | -$new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : ''; |
|
356 | -$new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : ''; |
|
357 | -$new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : ''; |
|
358 | -$new_user_send_password = $creating && isset( $_POST['send_password'] ) ? wp_unslash( $_POST['send_password'] ) : true; |
|
359 | -$new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : ''; |
|
352 | +$new_user_login = $creating && isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; |
|
353 | +$new_user_firstname = $creating && isset($_POST['first_name']) ? wp_unslash($_POST['first_name']) : ''; |
|
354 | +$new_user_lastname = $creating && isset($_POST['last_name']) ? wp_unslash($_POST['last_name']) : ''; |
|
355 | +$new_user_email = $creating && isset($_POST['email']) ? wp_unslash($_POST['email']) : ''; |
|
356 | +$new_user_uri = $creating && isset($_POST['url']) ? wp_unslash($_POST['url']) : ''; |
|
357 | +$new_user_role = $creating && isset($_POST['role']) ? wp_unslash($_POST['role']) : ''; |
|
358 | +$new_user_send_password = $creating && isset($_POST['send_password']) ? wp_unslash($_POST['send_password']) : true; |
|
359 | +$new_user_ignore_pass = $creating && isset($_POST['noconfirmation']) ? wp_unslash($_POST['noconfirmation']) : ''; |
|
360 | 360 | |
361 | 361 | ?> |
362 | 362 | <table class="form-table"> |
363 | 363 | <tr class="form-field form-required"> |
364 | 364 | <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
365 | - <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" /></td> |
|
365 | + <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" aria-required="true" autocapitalize="none" autocorrect="off" /></td> |
|
366 | 366 | </tr> |
367 | 367 | <tr class="form-field form-required"> |
368 | 368 | <th scope="row"><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
369 | - <td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td> |
|
369 | + <td><input name="email" type="email" id="email" value="<?php echo esc_attr($new_user_email); ?>" /></td> |
|
370 | 370 | </tr> |
371 | -<?php if ( !is_multisite() ) { ?> |
|
371 | +<?php if ( ! is_multisite()) { ?> |
|
372 | 372 | <tr class="form-field"> |
373 | 373 | <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th> |
374 | 374 | <td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr($new_user_firstname); ?>" /></td> |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | </tr> |
380 | 380 | <tr class="form-field"> |
381 | 381 | <th scope="row"><label for="url"><?php _e('Website') ?></label></th> |
382 | - <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td> |
|
382 | + <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr($new_user_uri); ?>" /></td> |
|
383 | 383 | </tr> |
384 | 384 | <?php |
385 | 385 | /** |
@@ -389,46 +389,46 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @param bool $show Whether to show the password fields. Default true. |
391 | 391 | */ |
392 | -if ( apply_filters( 'show_password_fields', true ) ) : ?> |
|
392 | +if (apply_filters('show_password_fields', true)) : ?> |
|
393 | 393 | <tr class="form-field form-required user-pass1-wrap"> |
394 | 394 | <th scope="row"> |
395 | 395 | <label for="pass1"> |
396 | - <?php _e( 'Password' ); ?> |
|
397 | - <span class="description hide-if-js"><?php _e( '(required)' ); ?></span> |
|
396 | + <?php _e('Password'); ?> |
|
397 | + <span class="description hide-if-js"><?php _e('(required)'); ?></span> |
|
398 | 398 | </label> |
399 | 399 | </th> |
400 | 400 | <td> |
401 | 401 | <input class="hidden" value=" " /><!-- #24364 workaround --> |
402 | - <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button> |
|
402 | + <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e('Show password'); ?></button> |
|
403 | 403 | <div class="wp-pwd hide-if-js"> |
404 | - <?php $initial_password = wp_generate_password( 24 ); ?> |
|
404 | + <?php $initial_password = wp_generate_password(24); ?> |
|
405 | 405 | <span class="password-input-wrapper"> |
406 | - <input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" /> |
|
406 | + <input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr($initial_password); ?>" aria-describedby="pass-strength-result" /> |
|
407 | 407 | </span> |
408 | - <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> |
|
408 | + <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Hide password'); ?>"> |
|
409 | 409 | <span class="dashicons dashicons-hidden"></span> |
410 | - <span class="text"><?php _e( 'Hide' ); ?></span> |
|
410 | + <span class="text"><?php _e('Hide'); ?></span> |
|
411 | 411 | </button> |
412 | - <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> |
|
413 | - <span class="text"><?php _e( 'Cancel' ); ?></span> |
|
412 | + <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Cancel password change'); ?>"> |
|
413 | + <span class="text"><?php _e('Cancel'); ?></span> |
|
414 | 414 | </button> |
415 | 415 | <div style="display:none" id="pass-strength-result" aria-live="polite"></div> |
416 | 416 | </div> |
417 | - <p><span class="description"><?php _e( 'A password reset link will be sent to the user via email.' ); ?></span></p> |
|
417 | + <p><span class="description"><?php _e('A password reset link will be sent to the user via email.'); ?></span></p> |
|
418 | 418 | </td> |
419 | 419 | </tr> |
420 | 420 | <tr class="form-field form-required user-pass2-wrap hide-if-js"> |
421 | - <th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> |
|
421 | + <th scope="row"><label for="pass2"><?php _e('Repeat Password'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
|
422 | 422 | <td> |
423 | 423 | <input name="pass2" type="password" id="pass2" autocomplete="off" /> |
424 | 424 | </td> |
425 | 425 | </tr> |
426 | 426 | <tr class="pw-weak"> |
427 | - <th><?php _e( 'Confirm Password' ); ?></th> |
|
427 | + <th><?php _e('Confirm Password'); ?></th> |
|
428 | 428 | <td> |
429 | 429 | <label> |
430 | 430 | <input type="checkbox" name="pw_weak" class="pw-checkbox" /> |
431 | - <?php _e( 'Confirm use of weak password' ); ?> |
|
431 | + <?php _e('Confirm use of weak password'); ?> |
|
432 | 432 | </label> |
433 | 433 | </td> |
434 | 434 | </tr> |
@@ -438,30 +438,30 @@ discard block |
||
438 | 438 | <th scope="row"><label for="role"><?php _e('Role'); ?></label></th> |
439 | 439 | <td><select name="role" id="role"> |
440 | 440 | <?php |
441 | - if ( !$new_user_role ) |
|
442 | - $new_user_role = !empty($current_role) ? $current_role : get_option('default_role'); |
|
441 | + if ( ! $new_user_role) |
|
442 | + $new_user_role = ! empty($current_role) ? $current_role : get_option('default_role'); |
|
443 | 443 | wp_dropdown_roles($new_user_role); |
444 | 444 | ?> |
445 | 445 | </select> |
446 | 446 | </td> |
447 | 447 | </tr> |
448 | - <?php if ( is_multisite() && is_super_admin() ) { ?> |
|
448 | + <?php if (is_multisite() && is_super_admin()) { ?> |
|
449 | 449 | <tr> |
450 | 450 | <th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th> |
451 | - <td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked( $new_user_ignore_pass ); ?> /> <?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label></td> |
|
451 | + <td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked($new_user_ignore_pass); ?> /> <?php _e('Add the user without sending an email that requires their confirmation.'); ?></label></td> |
|
452 | 452 | </tr> |
453 | 453 | <?php } ?> |
454 | 454 | </table> |
455 | 455 | |
456 | 456 | <?php |
457 | 457 | /** This action is documented in wp-admin/user-new.php */ |
458 | -do_action( 'user_new_form', 'add-new-user' ); |
|
458 | +do_action('user_new_form', 'add-new-user'); |
|
459 | 459 | ?> |
460 | 460 | |
461 | -<?php submit_button( __( 'Add New User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?> |
|
461 | +<?php submit_button(__('Add New User'), 'primary', 'createuser', true, array('id' => 'createusersub')); ?> |
|
462 | 462 | |
463 | 463 | </form> |
464 | 464 | <?php } // current_user_can('create_users') ?> |
465 | 465 | </div> |
466 | 466 | <?php |
467 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
467 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -10,9 +10,10 @@ discard block |
||
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | 12 | if ( is_multisite() ) { |
13 | - if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) |
|
14 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
15 | -} elseif ( ! current_user_can( 'create_users' ) ) { |
|
13 | + if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) { |
|
14 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
15 | + } |
|
16 | + } elseif ( ! current_user_can( 'create_users' ) ) { |
|
16 | 17 | wp_die( __( 'Cheatin’ uh?' ), 403 ); |
17 | 18 | } |
18 | 19 | |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | die(); |
60 | 61 | } |
61 | 62 | |
62 | - if ( ! current_user_can('promote_user', $user_details->ID) ) |
|
63 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
63 | + if ( ! current_user_can('promote_user', $user_details->ID) ) { |
|
64 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // Adding an existing user to this blog |
66 | 68 | $new_user_email = $user_details->user_email; |
@@ -96,8 +98,9 @@ discard block |
||
96 | 98 | } elseif ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) { |
97 | 99 | check_admin_referer( 'create-user', '_wpnonce_create-user' ); |
98 | 100 | |
99 | - if ( ! current_user_can('create_users') ) |
|
100 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
101 | + if ( ! current_user_can('create_users') ) { |
|
102 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
103 | + } |
|
101 | 104 | |
102 | 105 | if ( ! is_multisite() ) { |
103 | 106 | $user_id = edit_user(); |
@@ -105,10 +108,11 @@ discard block |
||
105 | 108 | if ( is_wp_error( $user_id ) ) { |
106 | 109 | $add_user_errors = $user_id; |
107 | 110 | } else { |
108 | - if ( current_user_can( 'list_users' ) ) |
|
109 | - $redirect = 'users.php?update=add&id=' . $user_id; |
|
110 | - else |
|
111 | - $redirect = add_query_arg( 'update', 'add', 'user-new.php' ); |
|
111 | + if ( current_user_can( 'list_users' ) ) { |
|
112 | + $redirect = 'users.php?update=add&id=' . $user_id; |
|
113 | + } else { |
|
114 | + $redirect = add_query_arg( 'update', 'add', 'user-new.php' ); |
|
115 | + } |
|
112 | 116 | wp_redirect( $redirect ); |
113 | 117 | die(); |
114 | 118 | } |
@@ -149,8 +153,9 @@ discard block |
||
149 | 153 | $parent_file = 'users.php'; |
150 | 154 | |
151 | 155 | $do_both = false; |
152 | -if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') ) |
|
156 | +if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') ) { |
|
153 | 157 | $do_both = true; |
158 | +} |
|
154 | 159 | |
155 | 160 | $help = '<p>' . __('To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.') . '</p>'; |
156 | 161 | |
@@ -231,8 +236,9 @@ discard block |
||
231 | 236 | break; |
232 | 237 | } |
233 | 238 | } else { |
234 | - if ( 'add' == $_GET['update'] ) |
|
235 | - $messages[] = __('User added.'); |
|
239 | + if ( 'add' == $_GET['update'] ) { |
|
240 | + $messages[] = __('User added.'); |
|
241 | + } |
|
236 | 242 | } |
237 | 243 | } |
238 | 244 | ?> |
@@ -249,23 +255,26 @@ discard block |
||
249 | 255 | <div class="error"> |
250 | 256 | <ul> |
251 | 257 | <?php |
252 | - foreach ( $errors->get_error_messages() as $err ) |
|
253 | - echo "<li>$err</li>\n"; |
|
258 | + foreach ( $errors->get_error_messages() as $err ) { |
|
259 | + echo "<li>$err</li>\n"; |
|
260 | + } |
|
254 | 261 | ?> |
255 | 262 | </ul> |
256 | 263 | </div> |
257 | 264 | <?php endif; |
258 | 265 | |
259 | 266 | if ( ! empty( $messages ) ) { |
260 | - foreach ( $messages as $msg ) |
|
261 | - echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
262 | -} ?> |
|
267 | + foreach ( $messages as $msg ) { |
|
268 | + echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
269 | + } |
|
270 | + } ?> |
|
263 | 271 | |
264 | 272 | <?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?> |
265 | 273 | <div class="error"> |
266 | 274 | <?php |
267 | - foreach ( $add_user_errors->get_error_messages() as $message ) |
|
268 | - echo "<p>$message</p>"; |
|
275 | + foreach ( $add_user_errors->get_error_messages() as $message ) { |
|
276 | + echo "<p>$message</p>"; |
|
277 | + } |
|
269 | 278 | ?> |
270 | 279 | </div> |
271 | 280 | <?php endif; ?> |
@@ -273,8 +282,9 @@ discard block |
||
273 | 282 | |
274 | 283 | <?php |
275 | 284 | if ( is_multisite() ) { |
276 | - if ( $do_both ) |
|
277 | - echo '<h3 id="add-existing-user">' . __('Add Existing User') . '</h3>'; |
|
285 | + if ( $do_both ) { |
|
286 | + echo '<h3 id="add-existing-user">' . __('Add Existing User') . '</h3>'; |
|
287 | + } |
|
278 | 288 | if ( !is_super_admin() ) { |
279 | 289 | echo '<p>' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
280 | 290 | $label = __('E-mail'); |
@@ -335,9 +345,10 @@ discard block |
||
335 | 345 | } // is_multisite() |
336 | 346 | |
337 | 347 | if ( current_user_can( 'create_users') ) { |
338 | - if ( $do_both ) |
|
339 | - echo '<h3 id="create-new-user">' . __( 'Add New User' ) . '</h3>'; |
|
340 | -?> |
|
348 | + if ( $do_both ) { |
|
349 | + echo '<h3 id="create-new-user">' . __( 'Add New User' ) . '</h3>'; |
|
350 | + } |
|
351 | + ?> |
|
341 | 352 | <p><?php _e('Create a brand new user and add them to this site.'); ?></p> |
342 | 353 | <form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"<?php |
343 | 354 | /** This action is documented in wp-admin/user-new.php */ |
@@ -438,8 +449,9 @@ discard block |
||
438 | 449 | <th scope="row"><label for="role"><?php _e('Role'); ?></label></th> |
439 | 450 | <td><select name="role" id="role"> |
440 | 451 | <?php |
441 | - if ( !$new_user_role ) |
|
442 | - $new_user_role = !empty($current_role) ? $current_role : get_option('default_role'); |
|
452 | + if ( !$new_user_role ) { |
|
453 | + $new_user_role = !empty($current_role) ? $current_role : get_option('default_role'); |
|
454 | + } |
|
443 | 455 | wp_dropdown_roles($new_user_role); |
444 | 456 | ?> |
445 | 457 | </select> |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The custom header image script. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * The custom header image script. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The custom header image class. |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | $this->admin_header_callback = $admin_header_callback; |
57 | 57 | $this->admin_image_div_callback = $admin_image_div_callback; |
58 | 58 | |
59 | - add_action( 'admin_menu', array( $this, 'init' ) ); |
|
59 | + add_action('admin_menu', array($this, 'init')); |
|
60 | 60 | |
61 | - add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) ); |
|
62 | - add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) ); |
|
63 | - add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) ); |
|
64 | - add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) ); |
|
61 | + add_action('customize_save_after', array($this, 'customize_set_last_used')); |
|
62 | + add_action('wp_ajax_custom-header-crop', array($this, 'ajax_header_crop')); |
|
63 | + add_action('wp_ajax_custom-header-add', array($this, 'ajax_header_add')); |
|
64 | + add_action('wp_ajax_custom-header-remove', array($this, 'ajax_header_remove')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | * @since 2.1.0 |
71 | 71 | */ |
72 | 72 | public function init() { |
73 | - $page = add_theme_page( __( 'Header' ), __( 'Header' ), 'edit_theme_options', 'custom-header', array( $this, 'admin_page' ) ); |
|
74 | - if ( ! $page ) { |
|
73 | + $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array($this, 'admin_page')); |
|
74 | + if ( ! $page) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - add_action( "admin_print_scripts-$page", array( $this, 'js_includes' ) ); |
|
79 | - add_action( "admin_print_styles-$page", array( $this, 'css_includes' ) ); |
|
80 | - add_action( "admin_head-$page", array( $this, 'help' ) ); |
|
81 | - add_action( "admin_head-$page", array( $this, 'take_action' ), 50 ); |
|
82 | - add_action( "admin_head-$page", array( $this, 'js' ), 50 ); |
|
83 | - if ( $this->admin_header_callback ) { |
|
84 | - add_action( "admin_head-$page", $this->admin_header_callback, 51 ); |
|
78 | + add_action("admin_print_scripts-$page", array($this, 'js_includes')); |
|
79 | + add_action("admin_print_styles-$page", array($this, 'css_includes')); |
|
80 | + add_action("admin_head-$page", array($this, 'help')); |
|
81 | + add_action("admin_head-$page", array($this, 'take_action'), 50); |
|
82 | + add_action("admin_head-$page", array($this, 'js'), 50); |
|
83 | + if ($this->admin_header_callback) { |
|
84 | + add_action("admin_head-$page", $this->admin_header_callback, 51); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -91,37 +91,37 @@ discard block |
||
91 | 91 | * @since 3.0.0 |
92 | 92 | */ |
93 | 93 | public function help() { |
94 | - get_current_screen()->add_help_tab( array( |
|
94 | + get_current_screen()->add_help_tab(array( |
|
95 | 95 | 'id' => 'overview', |
96 | 96 | 'title' => __('Overview'), |
97 | 97 | 'content' => |
98 | - '<p>' . __( 'This screen is used to customize the header section of your theme.') . '</p>' . |
|
99 | - '<p>' . __( 'You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.') . '<p>' |
|
100 | - ) ); |
|
98 | + '<p>'.__('This screen is used to customize the header section of your theme.').'</p>'. |
|
99 | + '<p>'.__('You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.').'<p>' |
|
100 | + )); |
|
101 | 101 | |
102 | - get_current_screen()->add_help_tab( array( |
|
102 | + get_current_screen()->add_help_tab(array( |
|
103 | 103 | 'id' => 'set-header-image', |
104 | 104 | 'title' => __('Header Image'), |
105 | 105 | 'content' => |
106 | - '<p>' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.' ) . '</p>' . |
|
107 | - '<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” button.' ) . '</p>' . |
|
108 | - '<p>' . __( 'If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.') . '</p>' . |
|
109 | - '<p>' . __( 'If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.') . '</p>' |
|
110 | - ) ); |
|
106 | + '<p>'.__('You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.').'</p>'. |
|
107 | + '<p>'.__('Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” button.').'</p>'. |
|
108 | + '<p>'.__('If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.').'</p>'. |
|
109 | + '<p>'.__('If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.').'</p>' |
|
110 | + )); |
|
111 | 111 | |
112 | - get_current_screen()->add_help_tab( array( |
|
112 | + get_current_screen()->add_help_tab(array( |
|
113 | 113 | 'id' => 'set-header-text', |
114 | 114 | 'title' => __('Header Text'), |
115 | 115 | 'content' => |
116 | - '<p>' . sprintf( __( 'For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%1$s">General Settings</a> section.' ), admin_url( 'options-general.php' ) ) . '<p>' . |
|
117 | - '<p>' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' . |
|
118 | - '<p>' . __( 'Don’t forget to click “Save Changes” when you’re done!') . '</p>' |
|
119 | - ) ); |
|
116 | + '<p>'.sprintf(__('For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%1$s">General Settings</a> section.'), admin_url('options-general.php')).'<p>'. |
|
117 | + '<p>'.__('In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.').'</p>'. |
|
118 | + '<p>'.__('Don’t forget to click “Save Changes” when you’re done!').'</p>' |
|
119 | + )); |
|
120 | 120 | |
121 | 121 | get_current_screen()->set_help_sidebar( |
122 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
123 | - '<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Header_Screen" target="_blank">Documentation on Custom Header</a>' ) . '</p>' . |
|
124 | - '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
|
122 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
123 | + '<p>'.__('<a href="https://codex.wordpress.org/Appearance_Header_Screen" target="_blank">Documentation on Custom Header</a>').'</p>'. |
|
124 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
125 | 125 | ); |
126 | 126 | } |
127 | 127 | |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @return int Current step |
134 | 134 | */ |
135 | 135 | public function step() { |
136 | - if ( ! isset( $_GET['step'] ) ) |
|
136 | + if ( ! isset($_GET['step'])) |
|
137 | 137 | return 1; |
138 | 138 | |
139 | 139 | $step = (int) $_GET['step']; |
140 | - if ( $step < 1 || 3 < $step || |
|
141 | - ( 2 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) || |
|
142 | - ( 3 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) ) |
|
140 | + if ($step < 1 || 3 < $step || |
|
141 | + (2 == $step && ! wp_verify_nonce($_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload')) || |
|
142 | + (3 == $step && ! wp_verify_nonce($_REQUEST['_wpnonce'], 'custom-header-crop-image')) |
|
143 | 143 | ) |
144 | 144 | return 1; |
145 | 145 | |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | public function js_includes() { |
155 | 155 | $step = $this->step(); |
156 | 156 | |
157 | - if ( ( 1 == $step || 3 == $step ) ) { |
|
157 | + if ((1 == $step || 3 == $step)) { |
|
158 | 158 | wp_enqueue_media(); |
159 | - wp_enqueue_script( 'custom-header' ); |
|
160 | - if ( current_theme_supports( 'custom-header', 'header-text' ) ) |
|
161 | - wp_enqueue_script( 'wp-color-picker' ); |
|
162 | - } elseif ( 2 == $step ) { |
|
159 | + wp_enqueue_script('custom-header'); |
|
160 | + if (current_theme_supports('custom-header', 'header-text')) |
|
161 | + wp_enqueue_script('wp-color-picker'); |
|
162 | + } elseif (2 == $step) { |
|
163 | 163 | wp_enqueue_script('imgareaselect'); |
164 | 164 | } |
165 | 165 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | public function css_includes() { |
173 | 173 | $step = $this->step(); |
174 | 174 | |
175 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
176 | - wp_enqueue_style( 'wp-color-picker' ); |
|
177 | - elseif ( 2 == $step ) |
|
175 | + if ((1 == $step || 3 == $step) && current_theme_supports('custom-header', 'header-text')) |
|
176 | + wp_enqueue_style('wp-color-picker'); |
|
177 | + elseif (2 == $step) |
|
178 | 178 | wp_enqueue_style('imgareaselect'); |
179 | 179 | } |
180 | 180 | |
@@ -184,42 +184,42 @@ discard block |
||
184 | 184 | * @since 2.6.0 |
185 | 185 | */ |
186 | 186 | public function take_action() { |
187 | - if ( ! current_user_can('edit_theme_options') ) |
|
187 | + if ( ! current_user_can('edit_theme_options')) |
|
188 | 188 | return; |
189 | 189 | |
190 | - if ( empty( $_POST ) ) |
|
190 | + if (empty($_POST)) |
|
191 | 191 | return; |
192 | 192 | |
193 | 193 | $this->updated = true; |
194 | 194 | |
195 | - if ( isset( $_POST['resetheader'] ) ) { |
|
196 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
195 | + if (isset($_POST['resetheader'])) { |
|
196 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
197 | 197 | $this->reset_header_image(); |
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
201 | - if ( isset( $_POST['removeheader'] ) ) { |
|
202 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
201 | + if (isset($_POST['removeheader'])) { |
|
202 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
203 | 203 | $this->remove_header_image(); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | - if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) { |
|
208 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
209 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
210 | - } elseif ( isset( $_POST['text-color'] ) ) { |
|
211 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
212 | - $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); |
|
207 | + if (isset($_POST['text-color']) && ! isset($_POST['display-header-text'])) { |
|
208 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
209 | + set_theme_mod('header_textcolor', 'blank'); |
|
210 | + } elseif (isset($_POST['text-color'])) { |
|
211 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
212 | + $_POST['text-color'] = str_replace('#', '', $_POST['text-color']); |
|
213 | 213 | $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); |
214 | - if ( strlen($color) == 6 || strlen($color) == 3 ) |
|
214 | + if (strlen($color) == 6 || strlen($color) == 3) |
|
215 | 215 | set_theme_mod('header_textcolor', $color); |
216 | - elseif ( ! $color ) |
|
217 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
216 | + elseif ( ! $color) |
|
217 | + set_theme_mod('header_textcolor', 'blank'); |
|
218 | 218 | } |
219 | 219 | |
220 | - if ( isset( $_POST['default-header'] ) ) { |
|
221 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
222 | - $this->set_header_image( $_POST['default-header'] ); |
|
220 | + if (isset($_POST['default-header'])) { |
|
221 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
222 | + $this->set_header_image($_POST['default-header']); |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | } |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | public function process_default_headers() { |
235 | 235 | global $_wp_default_headers; |
236 | 236 | |
237 | - if ( !isset($_wp_default_headers) ) |
|
237 | + if ( ! isset($_wp_default_headers)) |
|
238 | 238 | return; |
239 | 239 | |
240 | - if ( ! empty( $this->default_headers ) ) { |
|
240 | + if ( ! empty($this->default_headers)) { |
|
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->default_headers = $_wp_default_headers; |
245 | 245 | $template_directory_uri = get_template_directory_uri(); |
246 | 246 | $stylesheet_directory_uri = get_stylesheet_directory_uri(); |
247 | - foreach ( array_keys($this->default_headers) as $header ) { |
|
248 | - $this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri ); |
|
249 | - $this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri ); |
|
247 | + foreach (array_keys($this->default_headers) as $header) { |
|
248 | + $this->default_headers[$header]['url'] = sprintf($this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri); |
|
249 | + $this->default_headers[$header]['thumbnail_url'] = sprintf($this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -258,34 +258,34 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @since 3.0.0 |
260 | 260 | */ |
261 | - public function show_header_selector( $type = 'default' ) { |
|
262 | - if ( 'default' == $type ) { |
|
261 | + public function show_header_selector($type = 'default') { |
|
262 | + if ('default' == $type) { |
|
263 | 263 | $headers = $this->default_headers; |
264 | 264 | } else { |
265 | 265 | $headers = get_uploaded_header_images(); |
266 | 266 | $type = 'uploaded'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( 1 < count( $headers ) ) { |
|
269 | + if (1 < count($headers)) { |
|
270 | 270 | echo '<div class="random-header">'; |
271 | - echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />'; |
|
272 | - _e( '<strong>Random:</strong> Show a different image on each page.' ); |
|
271 | + echo '<label><input name="default-header" type="radio" value="random-'.$type.'-image"'.checked(is_random_header_image($type), true, false).' />'; |
|
272 | + _e('<strong>Random:</strong> Show a different image on each page.'); |
|
273 | 273 | echo '</label>'; |
274 | 274 | echo '</div>'; |
275 | 275 | } |
276 | 276 | |
277 | 277 | echo '<div class="available-headers">'; |
278 | - foreach ( $headers as $header_key => $header ) { |
|
278 | + foreach ($headers as $header_key => $header) { |
|
279 | 279 | $header_thumbnail = $header['thumbnail_url']; |
280 | 280 | $header_url = $header['url']; |
281 | - $header_desc = empty( $header['description'] ) ? '' : $header['description']; |
|
282 | - $header_alt_text = empty( $header['alt_text'] ) ? $header_desc : $header['alt_text']; |
|
281 | + $header_desc = empty($header['description']) ? '' : $header['description']; |
|
282 | + $header_alt_text = empty($header['alt_text']) ? $header_desc : $header['alt_text']; |
|
283 | 283 | echo '<div class="default-header">'; |
284 | - echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />'; |
|
284 | + echo '<label><input name="default-header" type="radio" value="'.esc_attr($header_key).'" '.checked($header_url, get_theme_mod('header_image'), false).' />'; |
|
285 | 285 | $width = ''; |
286 | - if ( !empty( $header['attachment_id'] ) ) |
|
286 | + if ( ! empty($header['attachment_id'])) |
|
287 | 287 | $width = ' width="230"'; |
288 | - echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) .'" title="' . esc_attr( $header_desc ) . '"' . $width . ' /></label>'; |
|
288 | + echo '<img src="'.set_url_scheme($header_thumbnail).'" alt="'.esc_attr($header_alt_text).'" title="'.esc_attr($header_desc).'"'.$width.' /></label>'; |
|
289 | 289 | echo '</div>'; |
290 | 290 | } |
291 | 291 | echo '<div class="clear"></div></div>'; |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function js() { |
300 | 300 | $step = $this->step(); |
301 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
301 | + if ((1 == $step || 3 == $step) && current_theme_supports('custom-header', 'header-text')) |
|
302 | 302 | $this->js_1(); |
303 | - elseif ( 2 == $step ) |
|
303 | + elseif (2 == $step) |
|
304 | 304 | $this->js_2(); |
305 | 305 | } |
306 | 306 | |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function js_1() { |
313 | 313 | $default_color = ''; |
314 | - if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { |
|
315 | - $default_color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
316 | - if ( $default_color && false === strpos( $default_color, '#' ) ) { |
|
317 | - $default_color = '#' . $default_color; |
|
314 | + if (current_theme_supports('custom-header', 'default-text-color')) { |
|
315 | + $default_color = get_theme_support('custom-header', 'default-text-color'); |
|
316 | + if ($default_color && false === strpos($default_color, '#')) { |
|
317 | + $default_color = '#'.$default_color; |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | ?> |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | }); |
358 | 358 | $('#display-header-text').click( toggle_text ); |
359 | - <?php if ( ! display_header_text() ) : ?> |
|
359 | + <?php if ( ! display_header_text()) : ?> |
|
360 | 360 | toggle_text(); |
361 | 361 | <?php endif; ?> |
362 | 362 | }); |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | jQuery(document).ready(function() { |
383 | - var xinit = <?php echo absint( get_theme_support( 'custom-header', 'width' ) ); ?>; |
|
384 | - var yinit = <?php echo absint( get_theme_support( 'custom-header', 'height' ) ); ?>; |
|
383 | + var xinit = <?php echo absint(get_theme_support('custom-header', 'width')); ?>; |
|
384 | + var yinit = <?php echo absint(get_theme_support('custom-header', 'height')); ?>; |
|
385 | 385 | var ratio = xinit / yinit; |
386 | 386 | var ximg = jQuery('img#upload').width(); |
387 | 387 | var yimg = jQuery('img#upload').height(); |
@@ -405,19 +405,19 @@ discard block |
||
405 | 405 | x2: xinit, |
406 | 406 | y2: yinit, |
407 | 407 | <?php |
408 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
408 | + if ( ! current_theme_supports('custom-header', 'flex-height') && ! current_theme_supports('custom-header', 'flex-width')) { |
|
409 | 409 | ?> |
410 | 410 | aspectRatio: xinit + ':' + yinit, |
411 | 411 | <?php |
412 | 412 | } |
413 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
413 | + if ( ! current_theme_supports('custom-header', 'flex-height')) { |
|
414 | 414 | ?> |
415 | - maxHeight: <?php echo get_theme_support( 'custom-header', 'height' ); ?>, |
|
415 | + maxHeight: <?php echo get_theme_support('custom-header', 'height'); ?>, |
|
416 | 416 | <?php |
417 | 417 | } |
418 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
418 | + if ( ! current_theme_supports('custom-header', 'flex-width')) { |
|
419 | 419 | ?> |
420 | - maxWidth: <?php echo get_theme_support( 'custom-header', 'width' ); ?>, |
|
420 | + maxWidth: <?php echo get_theme_support('custom-header', 'width'); ?>, |
|
421 | 421 | <?php |
422 | 422 | } |
423 | 423 | ?> |
@@ -447,112 +447,112 @@ discard block |
||
447 | 447 | ?> |
448 | 448 | |
449 | 449 | <div class="wrap"> |
450 | -<h1><?php _e( 'Custom Header' ); ?></h1> |
|
450 | +<h1><?php _e('Custom Header'); ?></h1> |
|
451 | 451 | |
452 | -<?php if ( current_user_can( 'customize' ) ) { ?> |
|
452 | +<?php if (current_user_can('customize')) { ?> |
|
453 | 453 | <div class="notice notice-info hide-if-no-customize"> |
454 | 454 | <p> |
455 | 455 | <?php |
456 | 456 | printf( |
457 | - __( 'You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.' ), |
|
458 | - admin_url( 'customize.php?autofocus[control]=header_image' ) |
|
457 | + __('You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.'), |
|
458 | + admin_url('customize.php?autofocus[control]=header_image') |
|
459 | 459 | ); |
460 | 460 | ?> |
461 | 461 | </p> |
462 | 462 | </div> |
463 | 463 | <?php } ?> |
464 | 464 | |
465 | -<?php if ( ! empty( $this->updated ) ) { ?> |
|
465 | +<?php if ( ! empty($this->updated)) { ?> |
|
466 | 466 | <div id="message" class="updated"> |
467 | -<p><?php printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p> |
|
467 | +<p><?php printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/')); ?></p> |
|
468 | 468 | </div> |
469 | 469 | <?php } ?> |
470 | 470 | |
471 | -<h3><?php _e( 'Header Image' ); ?></h3> |
|
471 | +<h3><?php _e('Header Image'); ?></h3> |
|
472 | 472 | |
473 | 473 | <table class="form-table"> |
474 | 474 | <tbody> |
475 | 475 | |
476 | -<?php if ( get_custom_header() || display_header_text() ) : ?> |
|
476 | +<?php if (get_custom_header() || display_header_text()) : ?> |
|
477 | 477 | <tr> |
478 | -<th scope="row"><?php _e( 'Preview' ); ?></th> |
|
478 | +<th scope="row"><?php _e('Preview'); ?></th> |
|
479 | 479 | <td> |
480 | 480 | <?php |
481 | - if ( $this->admin_image_div_callback ) { |
|
482 | - call_user_func( $this->admin_image_div_callback ); |
|
481 | + if ($this->admin_image_div_callback) { |
|
482 | + call_user_func($this->admin_image_div_callback); |
|
483 | 483 | } else { |
484 | 484 | $custom_header = get_custom_header(); |
485 | 485 | $header_image = get_header_image(); |
486 | 486 | |
487 | - if ( $header_image ) { |
|
488 | - $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; |
|
489 | - } else { |
|
487 | + if ($header_image) { |
|
488 | + $header_image_style = 'background-image:url('.esc_url($header_image).');'; |
|
489 | + } else { |
|
490 | 490 | $header_image_style = ''; |
491 | 491 | } |
492 | 492 | |
493 | - if ( $custom_header->width ) |
|
494 | - $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
|
495 | - if ( $custom_header->height ) |
|
496 | - $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
|
493 | + if ($custom_header->width) |
|
494 | + $header_image_style .= 'max-width:'.$custom_header->width.'px;'; |
|
495 | + if ($custom_header->height) |
|
496 | + $header_image_style .= 'height:'.$custom_header->height.'px;'; |
|
497 | 497 | ?> |
498 | 498 | <div id="headimg" style="<?php echo $header_image_style; ?>"> |
499 | 499 | <?php |
500 | - if ( display_header_text() ) |
|
501 | - $style = ' style="color:#' . get_header_textcolor() . ';"'; |
|
500 | + if (display_header_text()) |
|
501 | + $style = ' style="color:#'.get_header_textcolor().';"'; |
|
502 | 502 | else |
503 | 503 | $style = ' style="display:none;"'; |
504 | 504 | ?> |
505 | - <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
|
506 | - <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
|
505 | + <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1> |
|
506 | + <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo('description'); ?></div> |
|
507 | 507 | </div> |
508 | 508 | <?php } ?> |
509 | 509 | </td> |
510 | 510 | </tr> |
511 | 511 | <?php endif; ?> |
512 | 512 | |
513 | -<?php if ( current_user_can( 'upload_files' ) && current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
|
513 | +<?php if (current_user_can('upload_files') && current_theme_supports('custom-header', 'uploads')) : ?> |
|
514 | 514 | <tr> |
515 | -<th scope="row"><?php _e( 'Select Image' ); ?></th> |
|
515 | +<th scope="row"><?php _e('Select Image'); ?></th> |
|
516 | 516 | <td> |
517 | - <p><?php _e( 'You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.' ); ?><br /> |
|
517 | + <p><?php _e('You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.'); ?><br /> |
|
518 | 518 | <?php |
519 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
520 | - printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) ); |
|
521 | - } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
522 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
523 | - printf( __( 'Images should be at least <strong>%1$d pixels</strong> wide.' ) . ' ', get_theme_support( 'custom-header', 'width' ) ); |
|
524 | - } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
525 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) |
|
526 | - printf( __( 'Images should be at least <strong>%1$d pixels</strong> tall.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); |
|
519 | + if ( ! current_theme_supports('custom-header', 'flex-height') && ! current_theme_supports('custom-header', 'flex-width')) { |
|
520 | + printf(__('Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.').'<br />', get_theme_support('custom-header', 'width'), get_theme_support('custom-header', 'height')); |
|
521 | + } elseif (current_theme_supports('custom-header', 'flex-height')) { |
|
522 | + if ( ! current_theme_supports('custom-header', 'flex-width')) |
|
523 | + printf(__('Images should be at least <strong>%1$d pixels</strong> wide.').' ', get_theme_support('custom-header', 'width')); |
|
524 | + } elseif (current_theme_supports('custom-header', 'flex-width')) { |
|
525 | + if ( ! current_theme_supports('custom-header', 'flex-height')) |
|
526 | + printf(__('Images should be at least <strong>%1$d pixels</strong> tall.').' ', get_theme_support('custom-header', 'height')); |
|
527 | 527 | } |
528 | - if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
529 | - if ( current_theme_supports( 'custom-header', 'width' ) ) |
|
530 | - printf( __( 'Suggested width is <strong>%1$d pixels</strong>.' ) . ' ', get_theme_support( 'custom-header', 'width' ) ); |
|
531 | - if ( current_theme_supports( 'custom-header', 'height' ) ) |
|
532 | - printf( __( 'Suggested height is <strong>%1$d pixels</strong>.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); |
|
528 | + if (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width')) { |
|
529 | + if (current_theme_supports('custom-header', 'width')) |
|
530 | + printf(__('Suggested width is <strong>%1$d pixels</strong>.').' ', get_theme_support('custom-header', 'width')); |
|
531 | + if (current_theme_supports('custom-header', 'height')) |
|
532 | + printf(__('Suggested height is <strong>%1$d pixels</strong>.').' ', get_theme_support('custom-header', 'height')); |
|
533 | 533 | } |
534 | 534 | ?></p> |
535 | - <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ) ?>"> |
|
535 | + <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url(add_query_arg('step', 2)) ?>"> |
|
536 | 536 | <p> |
537 | - <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
|
537 | + <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /> |
|
538 | 538 | <input type="file" id="upload" name="import" /> |
539 | 539 | <input type="hidden" name="action" value="save" /> |
540 | - <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?> |
|
541 | - <?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?> |
|
540 | + <?php wp_nonce_field('custom-header-upload', '_wpnonce-custom-header-upload'); ?> |
|
541 | + <?php submit_button(__('Upload'), 'button', 'submit', false); ?> |
|
542 | 542 | </p> |
543 | 543 | <?php |
544 | - $modal_update_href = esc_url( add_query_arg( array( |
|
544 | + $modal_update_href = esc_url(add_query_arg(array( |
|
545 | 545 | 'page' => 'custom-header', |
546 | 546 | 'step' => 2, |
547 | 547 | '_wpnonce-custom-header-upload' => wp_create_nonce('custom-header-upload'), |
548 | - ), admin_url('themes.php') ) ); |
|
548 | + ), admin_url('themes.php'))); |
|
549 | 549 | ?> |
550 | 550 | <p> |
551 | - <label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br /> |
|
551 | + <label for="choose-from-library-link"><?php _e('Or choose an image from your media library:'); ?></label><br /> |
|
552 | 552 | <button id="choose-from-library-link" class="button" |
553 | - data-update-link="<?php echo esc_attr( $modal_update_href ); ?>" |
|
554 | - data-choose="<?php esc_attr_e( 'Choose a Custom Header' ); ?>" |
|
555 | - data-update="<?php esc_attr_e( 'Set as header' ); ?>"><?php _e( 'Choose Image' ); ?></button> |
|
553 | + data-update-link="<?php echo esc_attr($modal_update_href); ?>" |
|
554 | + data-choose="<?php esc_attr_e('Choose a Custom Header'); ?>" |
|
555 | + data-update="<?php esc_attr_e('Set as header'); ?>"><?php _e('Choose Image'); ?></button> |
|
556 | 556 | </p> |
557 | 557 | </form> |
558 | 558 | </td> |
@@ -561,97 +561,97 @@ discard block |
||
561 | 561 | </tbody> |
562 | 562 | </table> |
563 | 563 | |
564 | -<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ) ?>"> |
|
565 | -<?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?> |
|
564 | +<form method="post" action="<?php echo esc_url(add_query_arg('step', 1)) ?>"> |
|
565 | +<?php submit_button(null, 'screen-reader-text', 'save-header-options', false); ?> |
|
566 | 566 | <table class="form-table"> |
567 | 567 | <tbody> |
568 | - <?php if ( get_uploaded_header_images() ) : ?> |
|
568 | + <?php if (get_uploaded_header_images()) : ?> |
|
569 | 569 | <tr> |
570 | -<th scope="row"><?php _e( 'Uploaded Images' ); ?></th> |
|
570 | +<th scope="row"><?php _e('Uploaded Images'); ?></th> |
|
571 | 571 | <td> |
572 | - <p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ) ?></p> |
|
572 | + <p><?php _e('You can choose one of your previously uploaded headers, or show a random one.') ?></p> |
|
573 | 573 | <?php |
574 | - $this->show_header_selector( 'uploaded' ); |
|
574 | + $this->show_header_selector('uploaded'); |
|
575 | 575 | ?> |
576 | 576 | </td> |
577 | 577 | </tr> |
578 | 578 | <?php endif; |
579 | - if ( ! empty( $this->default_headers ) ) : ?> |
|
579 | + if ( ! empty($this->default_headers)) : ?> |
|
580 | 580 | <tr> |
581 | -<th scope="row"><?php _e( 'Default Images' ); ?></th> |
|
581 | +<th scope="row"><?php _e('Default Images'); ?></th> |
|
582 | 582 | <td> |
583 | -<?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
|
584 | - <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ) ?></p> |
|
583 | +<?php if (current_theme_supports('custom-header', 'uploads')) : ?> |
|
584 | + <p><?php _e('If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.') ?></p> |
|
585 | 585 | <?php else: ?> |
586 | - <p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ) ?></p> |
|
586 | + <p><?php _e('You can use one of these cool headers or show a random one on each page.') ?></p> |
|
587 | 587 | <?php endif; ?> |
588 | 588 | <?php |
589 | - $this->show_header_selector( 'default' ); |
|
589 | + $this->show_header_selector('default'); |
|
590 | 590 | ?> |
591 | 591 | </td> |
592 | 592 | </tr> |
593 | 593 | <?php endif; |
594 | - if ( get_header_image() ) : ?> |
|
594 | + if (get_header_image()) : ?> |
|
595 | 595 | <tr> |
596 | -<th scope="row"><?php _e( 'Remove Image' ); ?></th> |
|
596 | +<th scope="row"><?php _e('Remove Image'); ?></th> |
|
597 | 597 | <td> |
598 | - <p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ) ?></p> |
|
599 | - <?php submit_button( __( 'Remove Header Image' ), 'button', 'removeheader', false ); ?> |
|
598 | + <p><?php _e('This will remove the header image. You will not be able to restore any customizations.') ?></p> |
|
599 | + <?php submit_button(__('Remove Header Image'), 'button', 'removeheader', false); ?> |
|
600 | 600 | </td> |
601 | 601 | </tr> |
602 | 602 | <?php endif; |
603 | 603 | |
604 | - $default_image = get_theme_support( 'custom-header', 'default-image' ); |
|
605 | - if ( $default_image && get_header_image() != $default_image ) : ?> |
|
604 | + $default_image = get_theme_support('custom-header', 'default-image'); |
|
605 | + if ($default_image && get_header_image() != $default_image) : ?> |
|
606 | 606 | <tr> |
607 | -<th scope="row"><?php _e( 'Reset Image' ); ?></th> |
|
607 | +<th scope="row"><?php _e('Reset Image'); ?></th> |
|
608 | 608 | <td> |
609 | - <p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p> |
|
610 | - <?php submit_button( __( 'Restore Original Header Image' ), 'button', 'resetheader', false ); ?> |
|
609 | + <p><?php _e('This will restore the original header image. You will not be able to restore any customizations.') ?></p> |
|
610 | + <?php submit_button(__('Restore Original Header Image'), 'button', 'resetheader', false); ?> |
|
611 | 611 | </td> |
612 | 612 | </tr> |
613 | 613 | <?php endif; ?> |
614 | 614 | </tbody> |
615 | 615 | </table> |
616 | 616 | |
617 | -<?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?> |
|
617 | +<?php if (current_theme_supports('custom-header', 'header-text')) : ?> |
|
618 | 618 | |
619 | -<h3><?php _e( 'Header Text' ); ?></h3> |
|
619 | +<h3><?php _e('Header Text'); ?></h3> |
|
620 | 620 | |
621 | 621 | <table class="form-table"> |
622 | 622 | <tbody> |
623 | 623 | <tr> |
624 | -<th scope="row"><?php _e( 'Header Text' ); ?></th> |
|
624 | +<th scope="row"><?php _e('Header Text'); ?></th> |
|
625 | 625 | <td> |
626 | 626 | <p> |
627 | - <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked( display_header_text() ); ?> /> <?php _e( 'Show header text with your image.' ); ?></label> |
|
627 | + <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked(display_header_text()); ?> /> <?php _e('Show header text with your image.'); ?></label> |
|
628 | 628 | </p> |
629 | 629 | </td> |
630 | 630 | </tr> |
631 | 631 | |
632 | 632 | <tr class="displaying-header-text"> |
633 | -<th scope="row"><?php _e( 'Text Color' ); ?></th> |
|
633 | +<th scope="row"><?php _e('Text Color'); ?></th> |
|
634 | 634 | <td> |
635 | 635 | <p> |
636 | 636 | <?php |
637 | 637 | $default_color = ''; |
638 | - if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { |
|
639 | - $default_color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
640 | - if ( $default_color && false === strpos( $default_color, '#' ) ) { |
|
641 | - $default_color = '#' . $default_color; |
|
638 | + if (current_theme_supports('custom-header', 'default-text-color')) { |
|
639 | + $default_color = get_theme_support('custom-header', 'default-text-color'); |
|
640 | + if ($default_color && false === strpos($default_color, '#')) { |
|
641 | + $default_color = '#'.$default_color; |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | |
645 | - $default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : ''; |
|
645 | + $default_color_attr = $default_color ? ' data-default-color="'.esc_attr($default_color).'"' : ''; |
|
646 | 646 | |
647 | - $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' ); |
|
648 | - if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) { |
|
649 | - $header_textcolor = '#' . $header_textcolor; |
|
647 | + $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support('custom-header', 'default-text-color'); |
|
648 | + if ($header_textcolor && false === strpos($header_textcolor, '#')) { |
|
649 | + $header_textcolor = '#'.$header_textcolor; |
|
650 | 650 | } |
651 | 651 | |
652 | - echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr( $header_textcolor ) . '"' . $default_color_attr . ' />'; |
|
653 | - if ( $default_color ) { |
|
654 | - echo ' <span class="description hide-if-js">' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . '</span>'; |
|
652 | + echo '<input type="text" name="text-color" id="text-color" value="'.esc_attr($header_textcolor).'"'.$default_color_attr.' />'; |
|
653 | + if ($default_color) { |
|
654 | + echo ' <span class="description hide-if-js">'.sprintf(_x('Default: %s', 'color'), esc_html($default_color)).'</span>'; |
|
655 | 655 | } |
656 | 656 | ?> |
657 | 657 | </p> |
@@ -666,11 +666,11 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @since 3.1.0 |
668 | 668 | */ |
669 | -do_action( 'custom_header_options' ); |
|
669 | +do_action('custom_header_options'); |
|
670 | 670 | |
671 | -wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
|
671 | +wp_nonce_field('custom-header-options', '_wpnonce-custom-header-options'); ?> |
|
672 | 672 | |
673 | -<?php submit_button( null, 'primary', 'save-header-options' ); ?> |
|
673 | +<?php submit_button(null, 'primary', 'save-header-options'); ?> |
|
674 | 674 | </form> |
675 | 675 | </div> |
676 | 676 | |
@@ -683,48 +683,48 @@ discard block |
||
683 | 683 | */ |
684 | 684 | public function step_2() { |
685 | 685 | check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload'); |
686 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) |
|
687 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
686 | + if ( ! current_theme_supports('custom-header', 'uploads')) |
|
687 | + wp_die(__('Cheatin’ uh?'), 403); |
|
688 | 688 | |
689 | - if ( empty( $_POST ) && isset( $_GET['file'] ) ) { |
|
690 | - $attachment_id = absint( $_GET['file'] ); |
|
691 | - $file = get_attached_file( $attachment_id, true ); |
|
692 | - $url = wp_get_attachment_image_src( $attachment_id, 'full' ); |
|
689 | + if (empty($_POST) && isset($_GET['file'])) { |
|
690 | + $attachment_id = absint($_GET['file']); |
|
691 | + $file = get_attached_file($attachment_id, true); |
|
692 | + $url = wp_get_attachment_image_src($attachment_id, 'full'); |
|
693 | 693 | $url = $url[0]; |
694 | - } elseif ( isset( $_POST ) ) { |
|
694 | + } elseif (isset($_POST)) { |
|
695 | 695 | $data = $this->step_2_manage_upload(); |
696 | 696 | $attachment_id = $data['attachment_id']; |
697 | 697 | $file = $data['file']; |
698 | 698 | $url = $data['url']; |
699 | 699 | } |
700 | 700 | |
701 | - if ( file_exists( $file ) ) { |
|
702 | - list( $width, $height, $type, $attr ) = getimagesize( $file ); |
|
701 | + if (file_exists($file)) { |
|
702 | + list($width, $height, $type, $attr) = getimagesize($file); |
|
703 | 703 | } else { |
704 | - $data = wp_get_attachment_metadata( $attachment_id ); |
|
705 | - $height = isset( $data[ 'height' ] ) ? $data[ 'height' ] : 0; |
|
706 | - $width = isset( $data[ 'width' ] ) ? $data[ 'width' ] : 0; |
|
707 | - unset( $data ); |
|
704 | + $data = wp_get_attachment_metadata($attachment_id); |
|
705 | + $height = isset($data['height']) ? $data['height'] : 0; |
|
706 | + $width = isset($data['width']) ? $data['width'] : 0; |
|
707 | + unset($data); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $max_width = 0; |
711 | 711 | // For flex, limit size of image displayed to 1500px unless theme says otherwise |
712 | - if ( current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
712 | + if (current_theme_supports('custom-header', 'flex-width')) |
|
713 | 713 | $max_width = 1500; |
714 | 714 | |
715 | - if ( current_theme_supports( 'custom-header', 'max-width' ) ) |
|
716 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
717 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); |
|
715 | + if (current_theme_supports('custom-header', 'max-width')) |
|
716 | + $max_width = max($max_width, get_theme_support('custom-header', 'max-width')); |
|
717 | + $max_width = max($max_width, get_theme_support('custom-header', 'width')); |
|
718 | 718 | |
719 | 719 | // If flexible height isn't supported and the image is the exact right size |
720 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) |
|
721 | - && $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) |
|
720 | + if ( ! current_theme_supports('custom-header', 'flex-height') && ! current_theme_supports('custom-header', 'flex-width') |
|
721 | + && $width == get_theme_support('custom-header', 'width') && $height == get_theme_support('custom-header', 'height')) |
|
722 | 722 | { |
723 | 723 | // Add the meta-data |
724 | - if ( file_exists( $file ) ) |
|
725 | - wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
724 | + if (file_exists($file)) |
|
725 | + wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file)); |
|
726 | 726 | |
727 | - $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
|
727 | + $this->set_header_image(compact('url', 'attachment_id', 'width', 'height')); |
|
728 | 728 | |
729 | 729 | /** |
730 | 730 | * Fires after the header image is set or an error is returned. |
@@ -734,17 +734,17 @@ discard block |
||
734 | 734 | * @param string $file Path to the file. |
735 | 735 | * @param int $attachment_id Attachment ID. |
736 | 736 | */ |
737 | - do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication |
|
737 | + do_action('wp_create_file_in_uploads', $file, $attachment_id); // For replication |
|
738 | 738 | |
739 | 739 | return $this->finished(); |
740 | - } elseif ( $width > $max_width ) { |
|
740 | + } elseif ($width > $max_width) { |
|
741 | 741 | $oitar = $width / $max_width; |
742 | 742 | $image = wp_crop_image($attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
743 | - if ( ! $image || is_wp_error( $image ) ) |
|
744 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
743 | + if ( ! $image || is_wp_error($image)) |
|
744 | + wp_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error')); |
|
745 | 745 | |
746 | 746 | /** This filter is documented in wp-admin/custom-header.php */ |
747 | - $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication |
|
747 | + $image = apply_filters('wp_create_file_in_uploads', $image, $attachment_id); // For replication |
|
748 | 748 | |
749 | 749 | $url = str_replace(basename($url), basename($image), $url); |
750 | 750 | $width = $width / $oitar; |
@@ -755,32 +755,32 @@ discard block |
||
755 | 755 | ?> |
756 | 756 | |
757 | 757 | <div class="wrap"> |
758 | -<h1><?php _e( 'Crop Header Image' ); ?></h1> |
|
758 | +<h1><?php _e('Crop Header Image'); ?></h1> |
|
759 | 759 | |
760 | 760 | <form method="post" action="<?php echo esc_url(add_query_arg('step', 3)); ?>"> |
761 | 761 | <p class="hide-if-no-js"><?php _e('Choose the part of the image you want to use as your header.'); ?></p> |
762 | - <p class="hide-if-js"><strong><?php _e( 'You need JavaScript to choose a part of the image.'); ?></strong></p> |
|
762 | + <p class="hide-if-js"><strong><?php _e('You need JavaScript to choose a part of the image.'); ?></strong></p> |
|
763 | 763 | |
764 | 764 | <div id="crop_image" style="position: relative"> |
765 | - <img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /> |
|
765 | + <img src="<?php echo esc_url($url); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /> |
|
766 | 766 | </div> |
767 | 767 | |
768 | 768 | <input type="hidden" name="x1" id="x1" value="0"/> |
769 | 769 | <input type="hidden" name="y1" id="y1" value="0"/> |
770 | - <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/> |
|
771 | - <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/> |
|
772 | - <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $attachment_id ); ?>" /> |
|
773 | - <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> |
|
774 | - <?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?> |
|
770 | + <input type="hidden" name="width" id="width" value="<?php echo esc_attr($width); ?>"/> |
|
771 | + <input type="hidden" name="height" id="height" value="<?php echo esc_attr($height); ?>"/> |
|
772 | + <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($attachment_id); ?>" /> |
|
773 | + <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr($oitar); ?>" /> |
|
774 | + <?php if (empty($_POST) && isset($_GET['file'])) { ?> |
|
775 | 775 | <input type="hidden" name="create-new-attachment" value="true" /> |
776 | 776 | <?php } ?> |
777 | - <?php wp_nonce_field( 'custom-header-crop-image' ) ?> |
|
777 | + <?php wp_nonce_field('custom-header-crop-image') ?> |
|
778 | 778 | |
779 | 779 | <p class="submit"> |
780 | - <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?> |
|
780 | + <?php submit_button(__('Crop and Publish'), 'primary', 'submit', false); ?> |
|
781 | 781 | <?php |
782 | - if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) |
|
783 | - submit_button( __( 'Skip Cropping, Publish Image as Is' ), 'secondary', 'skip-cropping', false ); |
|
782 | + if (isset($oitar) && 1 == $oitar && (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width'))) |
|
783 | + submit_button(__('Skip Cropping, Publish Image as Is'), 'secondary', 'skip-cropping', false); |
|
784 | 784 | ?> |
785 | 785 | </p> |
786 | 786 | </form> |
@@ -798,14 +798,14 @@ discard block |
||
798 | 798 | $overrides = array('test_form' => false); |
799 | 799 | |
800 | 800 | $uploaded_file = $_FILES['import']; |
801 | - $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); |
|
802 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) |
|
803 | - wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
801 | + $wp_filetype = wp_check_filetype_and_ext($uploaded_file['tmp_name'], $uploaded_file['name']); |
|
802 | + if ( ! wp_match_mime_types('image', $wp_filetype['type'])) |
|
803 | + wp_die(__('The uploaded file is not a valid image. Please try again.')); |
|
804 | 804 | |
805 | 805 | $file = wp_handle_upload($uploaded_file, $overrides); |
806 | 806 | |
807 | - if ( isset($file['error']) ) |
|
808 | - wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
807 | + if (isset($file['error'])) |
|
808 | + wp_die($file['error'], __('Image Upload Error')); |
|
809 | 809 | |
810 | 810 | $url = $file['url']; |
811 | 811 | $type = $file['type']; |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Save the data |
825 | - $attachment_id = wp_insert_attachment( $object, $file ); |
|
826 | - return compact( 'attachment_id', 'file', 'filename', 'url', 'type' ); |
|
825 | + $attachment_id = wp_insert_attachment($object, $file); |
|
826 | + return compact('attachment_id', 'file', 'filename', 'url', 'type'); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -832,63 +832,63 @@ discard block |
||
832 | 832 | * @since 2.1.0 |
833 | 833 | */ |
834 | 834 | public function step_3() { |
835 | - check_admin_referer( 'custom-header-crop-image' ); |
|
835 | + check_admin_referer('custom-header-crop-image'); |
|
836 | 836 | |
837 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) |
|
838 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
837 | + if ( ! current_theme_supports('custom-header', 'uploads')) |
|
838 | + wp_die(__('Cheatin’ uh?'), 403); |
|
839 | 839 | |
840 | - if ( ! empty( $_POST['skip-cropping'] ) && ! ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) |
|
841 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
840 | + if ( ! empty($_POST['skip-cropping']) && ! (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width'))) |
|
841 | + wp_die(__('Cheatin’ uh?'), 403); |
|
842 | 842 | |
843 | - if ( $_POST['oitar'] > 1 ) { |
|
843 | + if ($_POST['oitar'] > 1) { |
|
844 | 844 | $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; |
845 | 845 | $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; |
846 | 846 | $_POST['width'] = $_POST['width'] * $_POST['oitar']; |
847 | 847 | $_POST['height'] = $_POST['height'] * $_POST['oitar']; |
848 | 848 | } |
849 | 849 | |
850 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
850 | + $attachment_id = absint($_POST['attachment_id']); |
|
851 | 851 | $original = get_attached_file($attachment_id); |
852 | 852 | |
853 | - $dimensions = $this->get_header_dimensions( array( |
|
853 | + $dimensions = $this->get_header_dimensions(array( |
|
854 | 854 | 'height' => $_POST['height'], |
855 | 855 | 'width' => $_POST['width'], |
856 | - ) ); |
|
856 | + )); |
|
857 | 857 | $height = $dimensions['dst_height']; |
858 | 858 | $width = $dimensions['dst_width']; |
859 | 859 | |
860 | - if ( empty( $_POST['skip-cropping'] ) ) |
|
861 | - $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); |
|
862 | - elseif ( ! empty( $_POST['create-new-attachment'] ) ) |
|
863 | - $cropped = _copy_image_file( $attachment_id ); |
|
860 | + if (empty($_POST['skip-cropping'])) |
|
861 | + $cropped = wp_crop_image($attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height); |
|
862 | + elseif ( ! empty($_POST['create-new-attachment'])) |
|
863 | + $cropped = _copy_image_file($attachment_id); |
|
864 | 864 | else |
865 | - $cropped = get_attached_file( $attachment_id ); |
|
865 | + $cropped = get_attached_file($attachment_id); |
|
866 | 866 | |
867 | - if ( ! $cropped || is_wp_error( $cropped ) ) |
|
868 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
867 | + if ( ! $cropped || is_wp_error($cropped)) |
|
868 | + wp_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error')); |
|
869 | 869 | |
870 | 870 | /** This filter is documented in wp-admin/custom-header.php */ |
871 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication |
|
871 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication |
|
872 | 872 | |
873 | - $object = $this->create_attachment_object( $cropped, $attachment_id ); |
|
873 | + $object = $this->create_attachment_object($cropped, $attachment_id); |
|
874 | 874 | |
875 | - if ( ! empty( $_POST['create-new-attachment'] ) ) |
|
876 | - unset( $object['ID'] ); |
|
875 | + if ( ! empty($_POST['create-new-attachment'])) |
|
876 | + unset($object['ID']); |
|
877 | 877 | |
878 | 878 | // Update the attachment |
879 | - $attachment_id = $this->insert_attachment( $object, $cropped ); |
|
879 | + $attachment_id = $this->insert_attachment($object, $cropped); |
|
880 | 880 | |
881 | 881 | $url = $object['guid']; |
882 | - $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
|
882 | + $this->set_header_image(compact('url', 'attachment_id', 'width', 'height')); |
|
883 | 883 | |
884 | 884 | // Cleanup. |
885 | - $medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original ); |
|
886 | - if ( file_exists( $medium ) ) { |
|
887 | - wp_delete_file( $medium ); |
|
885 | + $medium = str_replace(basename($original), 'midsize-'.basename($original), $original); |
|
886 | + if (file_exists($medium)) { |
|
887 | + wp_delete_file($medium); |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( empty( $_POST['create-new-attachment'] ) && empty( $_POST['skip-cropping'] ) ) { |
|
891 | - wp_delete_file( $original ); |
|
890 | + if (empty($_POST['create-new-attachment']) && empty($_POST['skip-cropping'])) { |
|
891 | + wp_delete_file($original); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | return $this->finished(); |
@@ -910,12 +910,12 @@ discard block |
||
910 | 910 | * @since 2.1.0 |
911 | 911 | */ |
912 | 912 | public function admin_page() { |
913 | - if ( ! current_user_can('edit_theme_options') ) |
|
913 | + if ( ! current_user_can('edit_theme_options')) |
|
914 | 914 | wp_die(__('You do not have permission to customize headers.')); |
915 | 915 | $step = $this->step(); |
916 | - if ( 2 == $step ) |
|
916 | + if (2 == $step) |
|
917 | 917 | $this->step_2(); |
918 | - elseif ( 3 == $step ) |
|
918 | + elseif (3 == $step) |
|
919 | 919 | $this->step_3(); |
920 | 920 | else |
921 | 921 | $this->step_1(); |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * @param array $form_fields |
930 | 930 | * @return array $form_fields |
931 | 931 | */ |
932 | - public function attachment_fields_to_edit( $form_fields ) { |
|
932 | + public function attachment_fields_to_edit($form_fields) { |
|
933 | 933 | return $form_fields; |
934 | 934 | } |
935 | 935 | |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | * @param array $tabs |
942 | 942 | * @return array $tabs |
943 | 943 | */ |
944 | - public function filter_upload_tabs( $tabs ) { |
|
944 | + public function filter_upload_tabs($tabs) { |
|
945 | 945 | return $tabs; |
946 | 946 | } |
947 | 947 | |
@@ -959,13 +959,13 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @param array|object|string $choice |
961 | 961 | */ |
962 | - final public function set_header_image( $choice ) { |
|
963 | - if ( is_array( $choice ) || is_object( $choice ) ) { |
|
962 | + final public function set_header_image($choice) { |
|
963 | + if (is_array($choice) || is_object($choice)) { |
|
964 | 964 | $choice = (array) $choice; |
965 | - if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) |
|
965 | + if ( ! isset($choice['attachment_id']) || ! isset($choice['url'])) |
|
966 | 966 | return; |
967 | 967 | |
968 | - $choice['url'] = esc_url_raw( $choice['url'] ); |
|
968 | + $choice['url'] = esc_url_raw($choice['url']); |
|
969 | 969 | |
970 | 970 | $header_image_data = (object) array( |
971 | 971 | 'attachment_id' => $choice['attachment_id'], |
@@ -975,32 +975,32 @@ discard block |
||
975 | 975 | 'width' => $choice['width'], |
976 | 976 | ); |
977 | 977 | |
978 | - update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
979 | - set_theme_mod( 'header_image', $choice['url'] ); |
|
980 | - set_theme_mod( 'header_image_data', $header_image_data ); |
|
978 | + update_post_meta($choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet()); |
|
979 | + set_theme_mod('header_image', $choice['url']); |
|
980 | + set_theme_mod('header_image_data', $header_image_data); |
|
981 | 981 | return; |
982 | 982 | } |
983 | 983 | |
984 | - if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ) ) ) { |
|
985 | - set_theme_mod( 'header_image', $choice ); |
|
986 | - remove_theme_mod( 'header_image_data' ); |
|
984 | + if (in_array($choice, array('remove-header', 'random-default-image', 'random-uploaded-image'))) { |
|
985 | + set_theme_mod('header_image', $choice); |
|
986 | + remove_theme_mod('header_image_data'); |
|
987 | 987 | return; |
988 | 988 | } |
989 | 989 | |
990 | 990 | $uploaded = get_uploaded_header_images(); |
991 | - if ( $uploaded && isset( $uploaded[ $choice ] ) ) { |
|
992 | - $header_image_data = $uploaded[ $choice ]; |
|
991 | + if ($uploaded && isset($uploaded[$choice])) { |
|
992 | + $header_image_data = $uploaded[$choice]; |
|
993 | 993 | |
994 | 994 | } else { |
995 | 995 | $this->process_default_headers(); |
996 | - if ( isset( $this->default_headers[ $choice ] ) ) |
|
997 | - $header_image_data = $this->default_headers[ $choice ]; |
|
996 | + if (isset($this->default_headers[$choice])) |
|
997 | + $header_image_data = $this->default_headers[$choice]; |
|
998 | 998 | else |
999 | 999 | return; |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); |
|
1003 | - set_theme_mod( 'header_image_data', $header_image_data ); |
|
1002 | + set_theme_mod('header_image', esc_url_raw($header_image_data['url'])); |
|
1003 | + set_theme_mod('header_image_data', $header_image_data); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | * @since 3.4.0 |
1010 | 1010 | */ |
1011 | 1011 | final public function remove_header_image() { |
1012 | - $this->set_header_image( 'remove-header' ); |
|
1012 | + $this->set_header_image('remove-header'); |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | /** |
@@ -1021,24 +1021,24 @@ discard block |
||
1021 | 1021 | */ |
1022 | 1022 | final public function reset_header_image() { |
1023 | 1023 | $this->process_default_headers(); |
1024 | - $default = get_theme_support( 'custom-header', 'default-image' ); |
|
1024 | + $default = get_theme_support('custom-header', 'default-image'); |
|
1025 | 1025 | |
1026 | - if ( ! $default ) { |
|
1026 | + if ( ! $default) { |
|
1027 | 1027 | $this->remove_header_image(); |
1028 | 1028 | return; |
1029 | 1029 | } |
1030 | - $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
1030 | + $default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
1031 | 1031 | |
1032 | 1032 | $default_data = array(); |
1033 | - foreach ( $this->default_headers as $header => $details ) { |
|
1034 | - if ( $details['url'] == $default ) { |
|
1033 | + foreach ($this->default_headers as $header => $details) { |
|
1034 | + if ($details['url'] == $default) { |
|
1035 | 1035 | $default_data = $details; |
1036 | 1036 | break; |
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 | |
1040 | - set_theme_mod( 'header_image', $default ); |
|
1041 | - set_theme_mod( 'header_image_data', (object) $default_data ); |
|
1040 | + set_theme_mod('header_image', $default); |
|
1041 | + set_theme_mod('header_image_data', (object) $default_data); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -1047,41 +1047,41 @@ discard block |
||
1047 | 1047 | * @param array $dimensions |
1048 | 1048 | * @return array dst_height and dst_width of header image. |
1049 | 1049 | */ |
1050 | - final public function get_header_dimensions( $dimensions ) { |
|
1050 | + final public function get_header_dimensions($dimensions) { |
|
1051 | 1051 | $max_width = 0; |
1052 | - $width = absint( $dimensions['width'] ); |
|
1053 | - $height = absint( $dimensions['height'] ); |
|
1054 | - $theme_height = get_theme_support( 'custom-header', 'height' ); |
|
1055 | - $theme_width = get_theme_support( 'custom-header', 'width' ); |
|
1056 | - $has_flex_width = current_theme_supports( 'custom-header', 'flex-width' ); |
|
1057 | - $has_flex_height = current_theme_supports( 'custom-header', 'flex-height' ); |
|
1058 | - $has_max_width = current_theme_supports( 'custom-header', 'max-width' ) ; |
|
1059 | - $dst = array( 'dst_height' => null, 'dst_width' => null ); |
|
1052 | + $width = absint($dimensions['width']); |
|
1053 | + $height = absint($dimensions['height']); |
|
1054 | + $theme_height = get_theme_support('custom-header', 'height'); |
|
1055 | + $theme_width = get_theme_support('custom-header', 'width'); |
|
1056 | + $has_flex_width = current_theme_supports('custom-header', 'flex-width'); |
|
1057 | + $has_flex_height = current_theme_supports('custom-header', 'flex-height'); |
|
1058 | + $has_max_width = current_theme_supports('custom-header', 'max-width'); |
|
1059 | + $dst = array('dst_height' => null, 'dst_width' => null); |
|
1060 | 1060 | |
1061 | 1061 | // For flex, limit size of image displayed to 1500px unless theme says otherwise |
1062 | - if ( $has_flex_width ) { |
|
1062 | + if ($has_flex_width) { |
|
1063 | 1063 | $max_width = 1500; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - if ( $has_max_width ) { |
|
1067 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
1066 | + if ($has_max_width) { |
|
1067 | + $max_width = max($max_width, get_theme_support('custom-header', 'max-width')); |
|
1068 | 1068 | } |
1069 | - $max_width = max( $max_width, $theme_width ); |
|
1069 | + $max_width = max($max_width, $theme_width); |
|
1070 | 1070 | |
1071 | - if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) { |
|
1072 | - $dst['dst_height'] = absint( $height * ( $max_width / $width ) ); |
|
1071 | + if ($has_flex_height && ( ! $has_flex_width || $width > $max_width)) { |
|
1072 | + $dst['dst_height'] = absint($height * ($max_width / $width)); |
|
1073 | 1073 | } |
1074 | - elseif ( $has_flex_height && $has_flex_width ) { |
|
1074 | + elseif ($has_flex_height && $has_flex_width) { |
|
1075 | 1075 | $dst['dst_height'] = $height; |
1076 | 1076 | } |
1077 | 1077 | else { |
1078 | 1078 | $dst['dst_height'] = $theme_height; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) { |
|
1082 | - $dst['dst_width'] = absint( $width * ( $max_width / $width ) ); |
|
1081 | + if ($has_flex_width && ( ! $has_flex_height || $width > $max_width)) { |
|
1082 | + $dst['dst_width'] = absint($width * ($max_width / $width)); |
|
1083 | 1083 | } |
1084 | - elseif ( $has_flex_width && $has_flex_height ) { |
|
1084 | + elseif ($has_flex_width && $has_flex_height) { |
|
1085 | 1085 | $dst['dst_width'] = $width; |
1086 | 1086 | } |
1087 | 1087 | else { |
@@ -1099,13 +1099,13 @@ discard block |
||
1099 | 1099 | * |
1100 | 1100 | * @return array Attachment object. |
1101 | 1101 | */ |
1102 | - final public function create_attachment_object( $cropped, $parent_attachment_id ) { |
|
1103 | - $parent = get_post( $parent_attachment_id ); |
|
1102 | + final public function create_attachment_object($cropped, $parent_attachment_id) { |
|
1103 | + $parent = get_post($parent_attachment_id); |
|
1104 | 1104 | $parent_url = $parent->guid; |
1105 | - $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); |
|
1105 | + $url = str_replace(basename($parent_url), basename($cropped), $parent_url); |
|
1106 | 1106 | |
1107 | - $size = @getimagesize( $cropped ); |
|
1108 | - $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
|
1107 | + $size = @getimagesize($cropped); |
|
1108 | + $image_type = ($size) ? $size['mime'] : 'image/jpeg'; |
|
1109 | 1109 | |
1110 | 1110 | $object = array( |
1111 | 1111 | 'ID' => $parent_attachment_id, |
@@ -1127,9 +1127,9 @@ discard block |
||
1127 | 1127 | * |
1128 | 1128 | * @return int Attachment ID. |
1129 | 1129 | */ |
1130 | - final public function insert_attachment( $object, $cropped ) { |
|
1131 | - $attachment_id = wp_insert_attachment( $object, $cropped ); |
|
1132 | - $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
|
1130 | + final public function insert_attachment($object, $cropped) { |
|
1131 | + $attachment_id = wp_insert_attachment($object, $cropped); |
|
1132 | + $metadata = wp_generate_attachment_metadata($attachment_id, $cropped); |
|
1133 | 1133 | /** |
1134 | 1134 | * Filter the header image attachment metadata. |
1135 | 1135 | * |
@@ -1139,8 +1139,8 @@ discard block |
||
1139 | 1139 | * |
1140 | 1140 | * @param array $metadata Attachment metadata. |
1141 | 1141 | */ |
1142 | - $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); |
|
1143 | - wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
1142 | + $metadata = apply_filters('wp_header_image_attachment_metadata', $metadata); |
|
1143 | + wp_update_attachment_metadata($attachment_id, $metadata); |
|
1144 | 1144 | return $attachment_id; |
1145 | 1145 | } |
1146 | 1146 | |
@@ -1149,24 +1149,24 @@ discard block |
||
1149 | 1149 | * new object. Returns JSON-encoded object details. |
1150 | 1150 | */ |
1151 | 1151 | public function ajax_header_crop() { |
1152 | - check_ajax_referer( 'image_editor-' . $_POST['id'], 'nonce' ); |
|
1152 | + check_ajax_referer('image_editor-'.$_POST['id'], 'nonce'); |
|
1153 | 1153 | |
1154 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1154 | + if ( ! current_user_can('edit_theme_options')) { |
|
1155 | 1155 | wp_send_json_error(); |
1156 | 1156 | } |
1157 | 1157 | |
1158 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
1158 | + if ( ! current_theme_supports('custom-header', 'uploads')) { |
|
1159 | 1159 | wp_send_json_error(); |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | $crop_details = $_POST['cropDetails']; |
1163 | 1163 | |
1164 | - $dimensions = $this->get_header_dimensions( array( |
|
1164 | + $dimensions = $this->get_header_dimensions(array( |
|
1165 | 1165 | 'height' => $crop_details['height'], |
1166 | 1166 | 'width' => $crop_details['width'], |
1167 | - ) ); |
|
1167 | + )); |
|
1168 | 1168 | |
1169 | - $attachment_id = absint( $_POST['id'] ); |
|
1169 | + $attachment_id = absint($_POST['id']); |
|
1170 | 1170 | |
1171 | 1171 | $cropped = wp_crop_image( |
1172 | 1172 | $attachment_id, |
@@ -1178,24 +1178,24 @@ discard block |
||
1178 | 1178 | (int) $dimensions['dst_height'] |
1179 | 1179 | ); |
1180 | 1180 | |
1181 | - if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
1182 | - wp_send_json_error( array( 'message' => __( 'Image could not be processed. Please go back and try again.' ) ) ); |
|
1181 | + if ( ! $cropped || is_wp_error($cropped)) { |
|
1182 | + wp_send_json_error(array('message' => __('Image could not be processed. Please go back and try again.'))); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** This filter is documented in wp-admin/custom-header.php */ |
1186 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication |
|
1186 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication |
|
1187 | 1187 | |
1188 | - $object = $this->create_attachment_object( $cropped, $attachment_id ); |
|
1188 | + $object = $this->create_attachment_object($cropped, $attachment_id); |
|
1189 | 1189 | |
1190 | - unset( $object['ID'] ); |
|
1190 | + unset($object['ID']); |
|
1191 | 1191 | |
1192 | - $new_attachment_id = $this->insert_attachment( $object, $cropped ); |
|
1192 | + $new_attachment_id = $this->insert_attachment($object, $cropped); |
|
1193 | 1193 | |
1194 | 1194 | $object['attachment_id'] = $new_attachment_id; |
1195 | 1195 | $object['width'] = $dimensions['dst_width']; |
1196 | 1196 | $object['height'] = $dimensions['dst_height']; |
1197 | 1197 | |
1198 | - wp_send_json_success( $object ); |
|
1198 | + wp_send_json_success($object); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | /** |
@@ -1206,20 +1206,20 @@ discard block |
||
1206 | 1206 | * Media Manager, even if s/he doesn't save that change. |
1207 | 1207 | */ |
1208 | 1208 | public function ajax_header_add() { |
1209 | - check_ajax_referer( 'header-add', 'nonce' ); |
|
1209 | + check_ajax_referer('header-add', 'nonce'); |
|
1210 | 1210 | |
1211 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1211 | + if ( ! current_user_can('edit_theme_options')) { |
|
1212 | 1212 | wp_send_json_error(); |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1216 | - if ( $attachment_id < 1 ) { |
|
1215 | + $attachment_id = absint($_POST['attachment_id']); |
|
1216 | + if ($attachment_id < 1) { |
|
1217 | 1217 | wp_send_json_error(); |
1218 | 1218 | } |
1219 | 1219 | |
1220 | - $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1221 | - update_post_meta( $attachment_id, $key, time() ); |
|
1222 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1220 | + $key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1221 | + update_post_meta($attachment_id, $key, time()); |
|
1222 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1223 | 1223 | |
1224 | 1224 | wp_send_json_success(); |
1225 | 1225 | } |
@@ -1232,20 +1232,20 @@ discard block |
||
1232 | 1232 | * choice in the Customizer's Header tool. |
1233 | 1233 | */ |
1234 | 1234 | public function ajax_header_remove() { |
1235 | - check_ajax_referer( 'header-remove', 'nonce' ); |
|
1235 | + check_ajax_referer('header-remove', 'nonce'); |
|
1236 | 1236 | |
1237 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1237 | + if ( ! current_user_can('edit_theme_options')) { |
|
1238 | 1238 | wp_send_json_error(); |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1242 | - if ( $attachment_id < 1 ) { |
|
1241 | + $attachment_id = absint($_POST['attachment_id']); |
|
1242 | + if ($attachment_id < 1) { |
|
1243 | 1243 | wp_send_json_error(); |
1244 | 1244 | } |
1245 | 1245 | |
1246 | - $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1247 | - delete_post_meta( $attachment_id, $key ); |
|
1248 | - delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1246 | + $key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1247 | + delete_post_meta($attachment_id, $key); |
|
1248 | + delete_post_meta($attachment_id, '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1249 | 1249 | |
1250 | 1250 | wp_send_json_success(); |
1251 | 1251 | } |
@@ -1254,16 +1254,16 @@ discard block |
||
1254 | 1254 | * |
1255 | 1255 | * @param WP_Customize_Manager $wp_customize |
1256 | 1256 | */ |
1257 | - public function customize_set_last_used( $wp_customize ) { |
|
1258 | - $data = $wp_customize->get_setting( 'header_image_data' )->post_value(); |
|
1257 | + public function customize_set_last_used($wp_customize) { |
|
1258 | + $data = $wp_customize->get_setting('header_image_data')->post_value(); |
|
1259 | 1259 | |
1260 | - if ( ! isset( $data['attachment_id'] ) ) { |
|
1260 | + if ( ! isset($data['attachment_id'])) { |
|
1261 | 1261 | return; |
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | $attachment_id = $data['attachment_id']; |
1265 | - $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1266 | - update_post_meta( $attachment_id, $key, time() ); |
|
1265 | + $key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1266 | + update_post_meta($attachment_id, $key, time()); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | /** |
@@ -1274,23 +1274,23 @@ discard block |
||
1274 | 1274 | $this->process_default_headers(); |
1275 | 1275 | |
1276 | 1276 | // Get the default image if there is one. |
1277 | - $default = get_theme_support( 'custom-header', 'default-image' ); |
|
1277 | + $default = get_theme_support('custom-header', 'default-image'); |
|
1278 | 1278 | |
1279 | - if ( ! $default ) { // If not, |
|
1279 | + if ( ! $default) { // If not, |
|
1280 | 1280 | return $this->default_headers; // easy peasy. |
1281 | 1281 | } |
1282 | 1282 | |
1283 | - $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
1283 | + $default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
1284 | 1284 | $already_has_default = false; |
1285 | 1285 | |
1286 | - foreach ( $this->default_headers as $k => $h ) { |
|
1287 | - if ( $h['url'] === $default ) { |
|
1286 | + foreach ($this->default_headers as $k => $h) { |
|
1287 | + if ($h['url'] === $default) { |
|
1288 | 1288 | $already_has_default = true; |
1289 | 1289 | break; |
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - if ( $already_has_default ) { |
|
1293 | + if ($already_has_default) { |
|
1294 | 1294 | return $this->default_headers; |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | ); |
1304 | 1304 | |
1305 | 1305 | // The rest of the set comes after. |
1306 | - return array_merge( $header_images, $this->default_headers ); |
|
1306 | + return array_merge($header_images, $this->default_headers); |
|
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | /** |
@@ -1312,13 +1312,13 @@ discard block |
||
1312 | 1312 | */ |
1313 | 1313 | public function get_uploaded_header_images() { |
1314 | 1314 | $header_images = get_uploaded_header_images(); |
1315 | - $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1315 | + $timestamp_key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1316 | 1316 | $alt_text_key = '_wp_attachment_image_alt'; |
1317 | 1317 | |
1318 | - foreach ( $header_images as &$header_image ) { |
|
1319 | - $header_meta = get_post_meta( $header_image['attachment_id'] ); |
|
1320 | - $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; |
|
1321 | - $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; |
|
1318 | + foreach ($header_images as &$header_image) { |
|
1319 | + $header_meta = get_post_meta($header_image['attachment_id']); |
|
1320 | + $header_image['timestamp'] = isset($header_meta[$timestamp_key]) ? $header_meta[$timestamp_key] : ''; |
|
1321 | + $header_image['alt_text'] = isset($header_meta[$alt_text_key]) ? $header_meta[$alt_text_key] : ''; |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | return $header_images; |
@@ -133,15 +133,17 @@ discard block |
||
133 | 133 | * @return int Current step |
134 | 134 | */ |
135 | 135 | public function step() { |
136 | - if ( ! isset( $_GET['step'] ) ) |
|
137 | - return 1; |
|
136 | + if ( ! isset( $_GET['step'] ) ) { |
|
137 | + return 1; |
|
138 | + } |
|
138 | 139 | |
139 | 140 | $step = (int) $_GET['step']; |
140 | 141 | if ( $step < 1 || 3 < $step || |
141 | 142 | ( 2 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) || |
142 | 143 | ( 3 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) ) |
143 | - ) |
|
144 | - return 1; |
|
144 | + ) { |
|
145 | + return 1; |
|
146 | + } |
|
145 | 147 | |
146 | 148 | return $step; |
147 | 149 | } |
@@ -157,8 +159,9 @@ discard block |
||
157 | 159 | if ( ( 1 == $step || 3 == $step ) ) { |
158 | 160 | wp_enqueue_media(); |
159 | 161 | wp_enqueue_script( 'custom-header' ); |
160 | - if ( current_theme_supports( 'custom-header', 'header-text' ) ) |
|
161 | - wp_enqueue_script( 'wp-color-picker' ); |
|
162 | + if ( current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
163 | + wp_enqueue_script( 'wp-color-picker' ); |
|
164 | + } |
|
162 | 165 | } elseif ( 2 == $step ) { |
163 | 166 | wp_enqueue_script('imgareaselect'); |
164 | 167 | } |
@@ -172,10 +175,11 @@ discard block |
||
172 | 175 | public function css_includes() { |
173 | 176 | $step = $this->step(); |
174 | 177 | |
175 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
176 | - wp_enqueue_style( 'wp-color-picker' ); |
|
177 | - elseif ( 2 == $step ) |
|
178 | - wp_enqueue_style('imgareaselect'); |
|
178 | + if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
179 | + wp_enqueue_style( 'wp-color-picker' ); |
|
180 | + } elseif ( 2 == $step ) { |
|
181 | + wp_enqueue_style('imgareaselect'); |
|
182 | + } |
|
179 | 183 | } |
180 | 184 | |
181 | 185 | /** |
@@ -184,11 +188,13 @@ discard block |
||
184 | 188 | * @since 2.6.0 |
185 | 189 | */ |
186 | 190 | public function take_action() { |
187 | - if ( ! current_user_can('edit_theme_options') ) |
|
188 | - return; |
|
191 | + if ( ! current_user_can('edit_theme_options') ) { |
|
192 | + return; |
|
193 | + } |
|
189 | 194 | |
190 | - if ( empty( $_POST ) ) |
|
191 | - return; |
|
195 | + if ( empty( $_POST ) ) { |
|
196 | + return; |
|
197 | + } |
|
192 | 198 | |
193 | 199 | $this->updated = true; |
194 | 200 | |
@@ -211,10 +217,11 @@ discard block |
||
211 | 217 | check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
212 | 218 | $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); |
213 | 219 | $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); |
214 | - if ( strlen($color) == 6 || strlen($color) == 3 ) |
|
215 | - set_theme_mod('header_textcolor', $color); |
|
216 | - elseif ( ! $color ) |
|
217 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
220 | + if ( strlen($color) == 6 || strlen($color) == 3 ) { |
|
221 | + set_theme_mod('header_textcolor', $color); |
|
222 | + } elseif ( ! $color ) { |
|
223 | + set_theme_mod( 'header_textcolor', 'blank' ); |
|
224 | + } |
|
218 | 225 | } |
219 | 226 | |
220 | 227 | if ( isset( $_POST['default-header'] ) ) { |
@@ -234,8 +241,9 @@ discard block |
||
234 | 241 | public function process_default_headers() { |
235 | 242 | global $_wp_default_headers; |
236 | 243 | |
237 | - if ( !isset($_wp_default_headers) ) |
|
238 | - return; |
|
244 | + if ( !isset($_wp_default_headers) ) { |
|
245 | + return; |
|
246 | + } |
|
239 | 247 | |
240 | 248 | if ( ! empty( $this->default_headers ) ) { |
241 | 249 | return; |
@@ -283,8 +291,9 @@ discard block |
||
283 | 291 | echo '<div class="default-header">'; |
284 | 292 | echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />'; |
285 | 293 | $width = ''; |
286 | - if ( !empty( $header['attachment_id'] ) ) |
|
287 | - $width = ' width="230"'; |
|
294 | + if ( !empty( $header['attachment_id'] ) ) { |
|
295 | + $width = ' width="230"'; |
|
296 | + } |
|
288 | 297 | echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) .'" title="' . esc_attr( $header_desc ) . '"' . $width . ' /></label>'; |
289 | 298 | echo '</div>'; |
290 | 299 | } |
@@ -298,10 +307,11 @@ discard block |
||
298 | 307 | */ |
299 | 308 | public function js() { |
300 | 309 | $step = $this->step(); |
301 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
302 | - $this->js_1(); |
|
303 | - elseif ( 2 == $step ) |
|
304 | - $this->js_2(); |
|
310 | + if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
311 | + $this->js_1(); |
|
312 | + } elseif ( 2 == $step ) { |
|
313 | + $this->js_2(); |
|
314 | + } |
|
305 | 315 | } |
306 | 316 | |
307 | 317 | /** |
@@ -486,21 +496,24 @@ discard block |
||
486 | 496 | |
487 | 497 | if ( $header_image ) { |
488 | 498 | $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; |
489 | - } else { |
|
499 | + } else { |
|
490 | 500 | $header_image_style = ''; |
491 | 501 | } |
492 | 502 | |
493 | - if ( $custom_header->width ) |
|
494 | - $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
|
495 | - if ( $custom_header->height ) |
|
496 | - $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
|
503 | + if ( $custom_header->width ) { |
|
504 | + $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
|
505 | + } |
|
506 | + if ( $custom_header->height ) { |
|
507 | + $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
|
508 | + } |
|
497 | 509 | ?> |
498 | 510 | <div id="headimg" style="<?php echo $header_image_style; ?>"> |
499 | 511 | <?php |
500 | - if ( display_header_text() ) |
|
501 | - $style = ' style="color:#' . get_header_textcolor() . ';"'; |
|
502 | - else |
|
503 | - $style = ' style="display:none;"'; |
|
512 | + if ( display_header_text() ) { |
|
513 | + $style = ' style="color:#' . get_header_textcolor() . ';"'; |
|
514 | + } else { |
|
515 | + $style = ' style="display:none;"'; |
|
516 | + } |
|
504 | 517 | ?> |
505 | 518 | <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
506 | 519 | <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
@@ -519,17 +532,21 @@ discard block |
||
519 | 532 | if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
520 | 533 | printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) ); |
521 | 534 | } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { |
522 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
523 | - printf( __( 'Images should be at least <strong>%1$d pixels</strong> wide.' ) . ' ', get_theme_support( 'custom-header', 'width' ) ); |
|
535 | + if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
536 | + printf( __( 'Images should be at least <strong>%1$d pixels</strong> wide.' ) . ' ', get_theme_support( 'custom-header', 'width' ) ); |
|
537 | + } |
|
524 | 538 | } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
525 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) |
|
526 | - printf( __( 'Images should be at least <strong>%1$d pixels</strong> tall.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); |
|
539 | + if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
540 | + printf( __( 'Images should be at least <strong>%1$d pixels</strong> tall.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); |
|
541 | + } |
|
527 | 542 | } |
528 | 543 | if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) { |
529 | - if ( current_theme_supports( 'custom-header', 'width' ) ) |
|
530 | - printf( __( 'Suggested width is <strong>%1$d pixels</strong>.' ) . ' ', get_theme_support( 'custom-header', 'width' ) ); |
|
531 | - if ( current_theme_supports( 'custom-header', 'height' ) ) |
|
532 | - printf( __( 'Suggested height is <strong>%1$d pixels</strong>.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); |
|
544 | + if ( current_theme_supports( 'custom-header', 'width' ) ) { |
|
545 | + printf( __( 'Suggested width is <strong>%1$d pixels</strong>.' ) . ' ', get_theme_support( 'custom-header', 'width' ) ); |
|
546 | + } |
|
547 | + if ( current_theme_supports( 'custom-header', 'height' ) ) { |
|
548 | + printf( __( 'Suggested height is <strong>%1$d pixels</strong>.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); |
|
549 | + } |
|
533 | 550 | } |
534 | 551 | ?></p> |
535 | 552 | <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ) ?>"> |
@@ -582,9 +599,12 @@ discard block |
||
582 | 599 | <td> |
583 | 600 | <?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
584 | 601 | <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ) ?></p> |
585 | -<?php else: ?> |
|
602 | +<?php else { |
|
603 | + : ?> |
|
586 | 604 | <p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ) ?></p> |
587 | -<?php endif; ?> |
|
605 | +<?php endif; |
|
606 | +} |
|
607 | +?> |
|
588 | 608 | <?php |
589 | 609 | $this->show_header_selector( 'default' ); |
590 | 610 | ?> |
@@ -683,8 +703,9 @@ discard block |
||
683 | 703 | */ |
684 | 704 | public function step_2() { |
685 | 705 | check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload'); |
686 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) |
|
687 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
706 | + if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
707 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
708 | + } |
|
688 | 709 | |
689 | 710 | if ( empty( $_POST ) && isset( $_GET['file'] ) ) { |
690 | 711 | $attachment_id = absint( $_GET['file'] ); |
@@ -709,11 +730,13 @@ discard block |
||
709 | 730 | |
710 | 731 | $max_width = 0; |
711 | 732 | // For flex, limit size of image displayed to 1500px unless theme says otherwise |
712 | - if ( current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
713 | - $max_width = 1500; |
|
733 | + if ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
734 | + $max_width = 1500; |
|
735 | + } |
|
714 | 736 | |
715 | - if ( current_theme_supports( 'custom-header', 'max-width' ) ) |
|
716 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
737 | + if ( current_theme_supports( 'custom-header', 'max-width' ) ) { |
|
738 | + $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
739 | + } |
|
717 | 740 | $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); |
718 | 741 | |
719 | 742 | // If flexible height isn't supported and the image is the exact right size |
@@ -721,8 +744,9 @@ discard block |
||
721 | 744 | && $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) |
722 | 745 | { |
723 | 746 | // Add the meta-data |
724 | - if ( file_exists( $file ) ) |
|
725 | - wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
747 | + if ( file_exists( $file ) ) { |
|
748 | + wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
749 | + } |
|
726 | 750 | |
727 | 751 | $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
728 | 752 | |
@@ -740,8 +764,9 @@ discard block |
||
740 | 764 | } elseif ( $width > $max_width ) { |
741 | 765 | $oitar = $width / $max_width; |
742 | 766 | $image = wp_crop_image($attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
743 | - if ( ! $image || is_wp_error( $image ) ) |
|
744 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
767 | + if ( ! $image || is_wp_error( $image ) ) { |
|
768 | + wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
769 | + } |
|
745 | 770 | |
746 | 771 | /** This filter is documented in wp-admin/custom-header.php */ |
747 | 772 | $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication |
@@ -779,8 +804,9 @@ discard block |
||
779 | 804 | <p class="submit"> |
780 | 805 | <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?> |
781 | 806 | <?php |
782 | - if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) |
|
783 | - submit_button( __( 'Skip Cropping, Publish Image as Is' ), 'secondary', 'skip-cropping', false ); |
|
807 | + if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) { |
|
808 | + submit_button( __( 'Skip Cropping, Publish Image as Is' ), 'secondary', 'skip-cropping', false ); |
|
809 | + } |
|
784 | 810 | ?> |
785 | 811 | </p> |
786 | 812 | </form> |
@@ -799,13 +825,15 @@ discard block |
||
799 | 825 | |
800 | 826 | $uploaded_file = $_FILES['import']; |
801 | 827 | $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); |
802 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) |
|
803 | - wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
828 | + if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { |
|
829 | + wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
830 | + } |
|
804 | 831 | |
805 | 832 | $file = wp_handle_upload($uploaded_file, $overrides); |
806 | 833 | |
807 | - if ( isset($file['error']) ) |
|
808 | - wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
834 | + if ( isset($file['error']) ) { |
|
835 | + wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
836 | + } |
|
809 | 837 | |
810 | 838 | $url = $file['url']; |
811 | 839 | $type = $file['type']; |
@@ -834,11 +862,13 @@ discard block |
||
834 | 862 | public function step_3() { |
835 | 863 | check_admin_referer( 'custom-header-crop-image' ); |
836 | 864 | |
837 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) |
|
838 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
865 | + if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
866 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
867 | + } |
|
839 | 868 | |
840 | - if ( ! empty( $_POST['skip-cropping'] ) && ! ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) |
|
841 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
869 | + if ( ! empty( $_POST['skip-cropping'] ) && ! ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) { |
|
870 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
871 | + } |
|
842 | 872 | |
843 | 873 | if ( $_POST['oitar'] > 1 ) { |
844 | 874 | $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; |
@@ -857,23 +887,26 @@ discard block |
||
857 | 887 | $height = $dimensions['dst_height']; |
858 | 888 | $width = $dimensions['dst_width']; |
859 | 889 | |
860 | - if ( empty( $_POST['skip-cropping'] ) ) |
|
861 | - $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); |
|
862 | - elseif ( ! empty( $_POST['create-new-attachment'] ) ) |
|
863 | - $cropped = _copy_image_file( $attachment_id ); |
|
864 | - else |
|
865 | - $cropped = get_attached_file( $attachment_id ); |
|
890 | + if ( empty( $_POST['skip-cropping'] ) ) { |
|
891 | + $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); |
|
892 | + } elseif ( ! empty( $_POST['create-new-attachment'] ) ) { |
|
893 | + $cropped = _copy_image_file( $attachment_id ); |
|
894 | + } else { |
|
895 | + $cropped = get_attached_file( $attachment_id ); |
|
896 | + } |
|
866 | 897 | |
867 | - if ( ! $cropped || is_wp_error( $cropped ) ) |
|
868 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
898 | + if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
899 | + wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
900 | + } |
|
869 | 901 | |
870 | 902 | /** This filter is documented in wp-admin/custom-header.php */ |
871 | 903 | $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication |
872 | 904 | |
873 | 905 | $object = $this->create_attachment_object( $cropped, $attachment_id ); |
874 | 906 | |
875 | - if ( ! empty( $_POST['create-new-attachment'] ) ) |
|
876 | - unset( $object['ID'] ); |
|
907 | + if ( ! empty( $_POST['create-new-attachment'] ) ) { |
|
908 | + unset( $object['ID'] ); |
|
909 | + } |
|
877 | 910 | |
878 | 911 | // Update the attachment |
879 | 912 | $attachment_id = $this->insert_attachment( $object, $cropped ); |
@@ -910,15 +943,17 @@ discard block |
||
910 | 943 | * @since 2.1.0 |
911 | 944 | */ |
912 | 945 | public function admin_page() { |
913 | - if ( ! current_user_can('edit_theme_options') ) |
|
914 | - wp_die(__('You do not have permission to customize headers.')); |
|
946 | + if ( ! current_user_can('edit_theme_options') ) { |
|
947 | + wp_die(__('You do not have permission to customize headers.')); |
|
948 | + } |
|
915 | 949 | $step = $this->step(); |
916 | - if ( 2 == $step ) |
|
917 | - $this->step_2(); |
|
918 | - elseif ( 3 == $step ) |
|
919 | - $this->step_3(); |
|
920 | - else |
|
921 | - $this->step_1(); |
|
950 | + if ( 2 == $step ) { |
|
951 | + $this->step_2(); |
|
952 | + } elseif ( 3 == $step ) { |
|
953 | + $this->step_3(); |
|
954 | + } else { |
|
955 | + $this->step_1(); |
|
956 | + } |
|
922 | 957 | } |
923 | 958 | |
924 | 959 | /** |
@@ -962,8 +997,9 @@ discard block |
||
962 | 997 | final public function set_header_image( $choice ) { |
963 | 998 | if ( is_array( $choice ) || is_object( $choice ) ) { |
964 | 999 | $choice = (array) $choice; |
965 | - if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) |
|
966 | - return; |
|
1000 | + if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) { |
|
1001 | + return; |
|
1002 | + } |
|
967 | 1003 | |
968 | 1004 | $choice['url'] = esc_url_raw( $choice['url'] ); |
969 | 1005 | |
@@ -993,10 +1029,11 @@ discard block |
||
993 | 1029 | |
994 | 1030 | } else { |
995 | 1031 | $this->process_default_headers(); |
996 | - if ( isset( $this->default_headers[ $choice ] ) ) |
|
997 | - $header_image_data = $this->default_headers[ $choice ]; |
|
998 | - else |
|
999 | - return; |
|
1032 | + if ( isset( $this->default_headers[ $choice ] ) ) { |
|
1033 | + $header_image_data = $this->default_headers[ $choice ]; |
|
1034 | + } else { |
|
1035 | + return; |
|
1036 | + } |
|
1000 | 1037 | } |
1001 | 1038 | |
1002 | 1039 | set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); |
@@ -1070,21 +1107,17 @@ discard block |
||
1070 | 1107 | |
1071 | 1108 | if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) { |
1072 | 1109 | $dst['dst_height'] = absint( $height * ( $max_width / $width ) ); |
1073 | - } |
|
1074 | - elseif ( $has_flex_height && $has_flex_width ) { |
|
1110 | + } elseif ( $has_flex_height && $has_flex_width ) { |
|
1075 | 1111 | $dst['dst_height'] = $height; |
1076 | - } |
|
1077 | - else { |
|
1112 | + } else { |
|
1078 | 1113 | $dst['dst_height'] = $theme_height; |
1079 | 1114 | } |
1080 | 1115 | |
1081 | 1116 | if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) { |
1082 | 1117 | $dst['dst_width'] = absint( $width * ( $max_width / $width ) ); |
1083 | - } |
|
1084 | - elseif ( $has_flex_width && $has_flex_height ) { |
|
1118 | + } elseif ( $has_flex_width && $has_flex_height ) { |
|
1085 | 1119 | $dst['dst_width'] = $width; |
1086 | - } |
|
1087 | - else { |
|
1120 | + } else { |
|
1088 | 1121 | $dst['dst_width'] = $theme_width; |
1089 | 1122 | } |
1090 | 1123 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Administration Bootstrap |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Administration Bootstrap |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * In WordPress Administration Screens |
@@ -11,40 +11,40 @@ discard block |
||
11 | 11 | * |
12 | 12 | * @since 2.3.2 |
13 | 13 | */ |
14 | -if ( ! defined( 'WP_ADMIN' ) ) { |
|
15 | - define( 'WP_ADMIN', true ); |
|
14 | +if ( ! defined('WP_ADMIN')) { |
|
15 | + define('WP_ADMIN', true); |
|
16 | 16 | } |
17 | 17 | |
18 | -if ( ! defined('WP_NETWORK_ADMIN') ) |
|
18 | +if ( ! defined('WP_NETWORK_ADMIN')) |
|
19 | 19 | define('WP_NETWORK_ADMIN', false); |
20 | 20 | |
21 | -if ( ! defined('WP_USER_ADMIN') ) |
|
21 | +if ( ! defined('WP_USER_ADMIN')) |
|
22 | 22 | define('WP_USER_ADMIN', false); |
23 | 23 | |
24 | -if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { |
|
24 | +if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN) { |
|
25 | 25 | define('WP_BLOG_ADMIN', true); |
26 | 26 | } |
27 | 27 | |
28 | -if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) |
|
28 | +if (isset($_GET['import']) && ! defined('WP_LOAD_IMPORTERS')) |
|
29 | 29 | define('WP_LOAD_IMPORTERS', true); |
30 | 30 | |
31 | -require_once(dirname(dirname(__FILE__)) . '/wp-load.php'); |
|
31 | +require_once(dirname(dirname(__FILE__)).'/wp-load.php'); |
|
32 | 32 | |
33 | 33 | nocache_headers(); |
34 | 34 | |
35 | -if ( get_option('db_upgraded') ) { |
|
35 | +if (get_option('db_upgraded')) { |
|
36 | 36 | flush_rewrite_rules(); |
37 | - update_option( 'db_upgraded', false ); |
|
37 | + update_option('db_upgraded', false); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Fires on the next page load after a successful DB upgrade. |
41 | 41 | * |
42 | 42 | * @since 2.8.0 |
43 | 43 | */ |
44 | - do_action( 'after_db_upgrade' ); |
|
45 | -} elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) { |
|
46 | - if ( !is_multisite() ) { |
|
47 | - wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
|
44 | + do_action('after_db_upgrade'); |
|
45 | +} elseif (get_option('db_version') != $wp_db_version && empty($_POST)) { |
|
46 | + if ( ! is_multisite()) { |
|
47 | + wp_redirect(admin_url('upgrade.php?_wp_http_referer='.urlencode(wp_unslash($_SERVER['REQUEST_URI'])))); |
|
48 | 48 | exit; |
49 | 49 | |
50 | 50 | /** |
@@ -61,30 +61,30 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param bool true Whether to perform the Multisite upgrade routine. Default true. |
63 | 63 | */ |
64 | - } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
|
64 | + } elseif (apply_filters('do_mu_upgrade', true)) { |
|
65 | 65 | $c = get_blog_count(); |
66 | 66 | |
67 | 67 | /* |
68 | 68 | * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
69 | 69 | * attempt to do no more than threshold value, with some +/- allowed. |
70 | 70 | */ |
71 | - if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
|
72 | - require_once( ABSPATH . WPINC . '/http.php' ); |
|
73 | - $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
|
71 | + if ($c <= 50 || ($c > 50 && mt_rand(0, (int) ($c / 50)) == 1)) { |
|
72 | + require_once(ABSPATH.WPINC.'/http.php'); |
|
73 | + $response = wp_remote_get(admin_url('upgrade.php?step=1'), array('timeout' => 120, 'httpversion' => '1.1')); |
|
74 | 74 | /** This action is documented in wp-admin/network/upgrade.php */ |
75 | - do_action( 'after_mu_upgrade', $response ); |
|
75 | + do_action('after_mu_upgrade', $response); |
|
76 | 76 | unset($response); |
77 | 77 | } |
78 | 78 | unset($c); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | -require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
82 | +require_once(ABSPATH.'wp-admin/includes/admin.php'); |
|
83 | 83 | |
84 | 84 | auth_redirect(); |
85 | 85 | |
86 | 86 | // Schedule trash collection |
87 | -if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) |
|
87 | +if ( ! wp_next_scheduled('wp_scheduled_delete') && ! defined('WP_INSTALLING')) |
|
88 | 88 | wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); |
89 | 89 | |
90 | 90 | set_screen_options(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $date_format = get_option('date_format'); |
93 | 93 | $time_format = get_option('time_format'); |
94 | 94 | |
95 | -wp_enqueue_script( 'common' ); |
|
95 | +wp_enqueue_script('common'); |
|
96 | 96 | |
97 | 97 | |
98 | 98 | |
@@ -115,29 +115,29 @@ discard block |
||
115 | 115 | |
116 | 116 | $editing = false; |
117 | 117 | |
118 | -if ( isset($_GET['page']) ) { |
|
119 | - $plugin_page = wp_unslash( $_GET['page'] ); |
|
118 | +if (isset($_GET['page'])) { |
|
119 | + $plugin_page = wp_unslash($_GET['page']); |
|
120 | 120 | $plugin_page = plugin_basename($plugin_page); |
121 | 121 | } |
122 | 122 | |
123 | -if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
123 | +if (isset($_REQUEST['post_type']) && post_type_exists($_REQUEST['post_type'])) |
|
124 | 124 | $typenow = $_REQUEST['post_type']; |
125 | 125 | else |
126 | 126 | $typenow = ''; |
127 | 127 | |
128 | -if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) |
|
128 | +if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) |
|
129 | 129 | $taxnow = $_REQUEST['taxonomy']; |
130 | 130 | else |
131 | 131 | $taxnow = ''; |
132 | 132 | |
133 | -if ( WP_NETWORK_ADMIN ) |
|
134 | - require(ABSPATH . 'wp-admin/network/menu.php'); |
|
135 | -elseif ( WP_USER_ADMIN ) |
|
136 | - require(ABSPATH . 'wp-admin/user/menu.php'); |
|
133 | +if (WP_NETWORK_ADMIN) |
|
134 | + require(ABSPATH.'wp-admin/network/menu.php'); |
|
135 | +elseif (WP_USER_ADMIN) |
|
136 | + require(ABSPATH.'wp-admin/user/menu.php'); |
|
137 | 137 | else |
138 | - require(ABSPATH . 'wp-admin/menu.php'); |
|
138 | + require(ABSPATH.'wp-admin/menu.php'); |
|
139 | 139 | |
140 | -if ( current_user_can( 'manage_options' ) ) { |
|
140 | +if (current_user_can('manage_options')) { |
|
141 | 141 | /** |
142 | 142 | * Filter the maximum memory limit available for administration screens. |
143 | 143 | * |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string 'WP_MAX_MEMORY_LIMIT' The maximum WordPress memory limit. Default 256M. |
154 | 154 | */ |
155 | - @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
155 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,24 +165,24 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @since 2.5.0 |
167 | 167 | */ |
168 | -do_action( 'admin_init' ); |
|
168 | +do_action('admin_init'); |
|
169 | 169 | |
170 | -if ( isset($plugin_page) ) { |
|
171 | - if ( !empty($typenow) ) |
|
172 | - $the_parent = $pagenow . '?post_type=' . $typenow; |
|
170 | +if (isset($plugin_page)) { |
|
171 | + if ( ! empty($typenow)) |
|
172 | + $the_parent = $pagenow.'?post_type='.$typenow; |
|
173 | 173 | else |
174 | 174 | $the_parent = $pagenow; |
175 | - if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
|
175 | + if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent)) { |
|
176 | 176 | $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
177 | 177 | |
178 | 178 | // Backwards compatibility for plugins using add_management_page(). |
179 | - if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
|
179 | + if (empty($page_hook) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php')) { |
|
180 | 180 | // There could be plugin specific params on the URL, so we need the whole query string |
181 | - if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
|
182 | - $query_string = $_SERVER[ 'QUERY_STRING' ]; |
|
181 | + if ( ! empty($_SERVER['QUERY_STRING'])) |
|
182 | + $query_string = $_SERVER['QUERY_STRING']; |
|
183 | 183 | else |
184 | - $query_string = 'page=' . $plugin_page; |
|
185 | - wp_redirect( admin_url('tools.php?' . $query_string) ); |
|
184 | + $query_string = 'page='.$plugin_page; |
|
185 | + wp_redirect(admin_url('tools.php?'.$query_string)); |
|
186 | 186 | exit; |
187 | 187 | } |
188 | 188 | } |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | $hook_suffix = ''; |
193 | -if ( isset( $page_hook ) ) { |
|
193 | +if (isset($page_hook)) { |
|
194 | 194 | $hook_suffix = $page_hook; |
195 | -} elseif ( isset( $plugin_page ) ) { |
|
195 | +} elseif (isset($plugin_page)) { |
|
196 | 196 | $hook_suffix = $plugin_page; |
197 | -} elseif ( isset( $pagenow ) ) { |
|
197 | +} elseif (isset($pagenow)) { |
|
198 | 198 | $hook_suffix = $pagenow; |
199 | 199 | } |
200 | 200 | |
201 | 201 | set_current_screen(); |
202 | 202 | |
203 | 203 | // Handle plugin admin pages. |
204 | -if ( isset($plugin_page) ) { |
|
205 | - if ( $page_hook ) { |
|
204 | +if (isset($plugin_page)) { |
|
205 | + if ($page_hook) { |
|
206 | 206 | /** |
207 | 207 | * Fires before a particular screen is loaded. |
208 | 208 | * |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @since 2.1.0 |
225 | 225 | */ |
226 | - do_action( 'load-' . $page_hook ); |
|
227 | - if (! isset($_GET['noheader'])) |
|
228 | - require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
226 | + do_action('load-'.$page_hook); |
|
227 | + if ( ! isset($_GET['noheader'])) |
|
228 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Used to call the registered callback for a plugin screen. |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | * @ignore |
234 | 234 | * @since 1.5.0 |
235 | 235 | */ |
236 | - do_action( $page_hook ); |
|
236 | + do_action($page_hook); |
|
237 | 237 | } else { |
238 | - if ( validate_file($plugin_page) ) |
|
238 | + if (validate_file($plugin_page)) |
|
239 | 239 | wp_die(__('Invalid plugin page')); |
240 | 240 | |
241 | - if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) ) |
|
241 | + if ( ! (file_exists(WP_PLUGIN_DIR."/$plugin_page") && is_file(WP_PLUGIN_DIR."/$plugin_page")) && ! (file_exists(WPMU_PLUGIN_DIR."/$plugin_page") && is_file(WPMU_PLUGIN_DIR."/$plugin_page"))) |
|
242 | 242 | wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
243 | 243 | |
244 | 244 | /** |
@@ -253,34 +253,34 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @since 1.5.0 |
255 | 255 | */ |
256 | - do_action( 'load-' . $plugin_page ); |
|
256 | + do_action('load-'.$plugin_page); |
|
257 | 257 | |
258 | - if ( !isset($_GET['noheader'])) |
|
259 | - require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
258 | + if ( ! isset($_GET['noheader'])) |
|
259 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
260 | 260 | |
261 | - if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) |
|
262 | - include(WPMU_PLUGIN_DIR . "/$plugin_page"); |
|
261 | + if (file_exists(WPMU_PLUGIN_DIR."/$plugin_page")) |
|
262 | + include(WPMU_PLUGIN_DIR."/$plugin_page"); |
|
263 | 263 | else |
264 | - include(WP_PLUGIN_DIR . "/$plugin_page"); |
|
264 | + include(WP_PLUGIN_DIR."/$plugin_page"); |
|
265 | 265 | } |
266 | 266 | |
267 | - include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
267 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
268 | 268 | |
269 | 269 | exit(); |
270 | -} elseif ( isset( $_GET['import'] ) ) { |
|
270 | +} elseif (isset($_GET['import'])) { |
|
271 | 271 | |
272 | 272 | $importer = $_GET['import']; |
273 | 273 | |
274 | - if ( ! current_user_can('import') ) |
|
274 | + if ( ! current_user_can('import')) |
|
275 | 275 | wp_die(__('You are not allowed to import.')); |
276 | 276 | |
277 | - if ( validate_file($importer) ) { |
|
278 | - wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
|
277 | + if (validate_file($importer)) { |
|
278 | + wp_redirect(admin_url('import.php?invalid='.$importer)); |
|
279 | 279 | exit; |
280 | 280 | } |
281 | 281 | |
282 | - if ( ! isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2]) ) { |
|
283 | - wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
|
282 | + if ( ! isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2])) { |
|
283 | + wp_redirect(admin_url('import.php?invalid='.$importer)); |
|
284 | 284 | exit; |
285 | 285 | } |
286 | 286 | |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @since 3.5.0 |
293 | 293 | */ |
294 | - do_action( 'load-importer-' . $importer ); |
|
294 | + do_action('load-importer-'.$importer); |
|
295 | 295 | |
296 | 296 | $parent_file = 'tools.php'; |
297 | 297 | $submenu_file = 'import.php'; |
298 | 298 | $title = __('Import'); |
299 | 299 | |
300 | - if (! isset($_GET['noheader'])) |
|
301 | - require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
300 | + if ( ! isset($_GET['noheader'])) |
|
301 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
302 | 302 | |
303 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
303 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
304 | 304 | |
305 | 305 | define('WP_IMPORTING', true); |
306 | 306 | |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @param bool false Whether to force data to be filtered through kses. Default false. |
316 | 316 | */ |
317 | - if ( apply_filters( 'force_filtered_html_on_import', false ) ) { |
|
318 | - kses_init_filters(); // Always filter imported data with kses on multisite. |
|
317 | + if (apply_filters('force_filtered_html_on_import', false)) { |
|
318 | + kses_init_filters(); // Always filter imported data with kses on multisite. |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | call_user_func($wp_importers[$importer][2]); |
322 | 322 | |
323 | - include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
323 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
324 | 324 | |
325 | 325 | // Make sure rules are flushed |
326 | 326 | flush_rewrite_rules(false); |
@@ -339,26 +339,26 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @since 2.1.0 |
341 | 341 | */ |
342 | - do_action( 'load-' . $pagenow ); |
|
342 | + do_action('load-'.$pagenow); |
|
343 | 343 | |
344 | 344 | /* |
345 | 345 | * The following hooks are fired to ensure backward compatibility. |
346 | 346 | * In all other cases, 'load-' . $pagenow should be used instead. |
347 | 347 | */ |
348 | - if ( $typenow == 'page' ) { |
|
349 | - if ( $pagenow == 'post-new.php' ) |
|
350 | - do_action( 'load-page-new.php' ); |
|
351 | - elseif ( $pagenow == 'post.php' ) |
|
352 | - do_action( 'load-page.php' ); |
|
353 | - } elseif ( $pagenow == 'edit-tags.php' ) { |
|
354 | - if ( $taxnow == 'category' ) |
|
355 | - do_action( 'load-categories.php' ); |
|
356 | - elseif ( $taxnow == 'link_category' ) |
|
357 | - do_action( 'load-edit-link-categories.php' ); |
|
348 | + if ($typenow == 'page') { |
|
349 | + if ($pagenow == 'post-new.php') |
|
350 | + do_action('load-page-new.php'); |
|
351 | + elseif ($pagenow == 'post.php') |
|
352 | + do_action('load-page.php'); |
|
353 | + } elseif ($pagenow == 'edit-tags.php') { |
|
354 | + if ($taxnow == 'category') |
|
355 | + do_action('load-categories.php'); |
|
356 | + elseif ($taxnow == 'link_category') |
|
357 | + do_action('load-edit-link-categories.php'); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | -if ( ! empty( $_REQUEST['action'] ) ) { |
|
361 | +if ( ! empty($_REQUEST['action'])) { |
|
362 | 362 | /** |
363 | 363 | * Fires when an 'action' request variable is sent. |
364 | 364 | * |
@@ -367,5 +367,5 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @since 2.6.0 |
369 | 369 | */ |
370 | - do_action( 'admin_action_' . $_REQUEST['action'] ); |
|
370 | + do_action('admin_action_'.$_REQUEST['action']); |
|
371 | 371 | } |
@@ -15,18 +15,21 @@ discard block |
||
15 | 15 | define( 'WP_ADMIN', true ); |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! defined('WP_NETWORK_ADMIN') ) |
|
18 | +if ( ! defined('WP_NETWORK_ADMIN') ) { |
|
19 | 19 | define('WP_NETWORK_ADMIN', false); |
20 | +} |
|
20 | 21 | |
21 | -if ( ! defined('WP_USER_ADMIN') ) |
|
22 | +if ( ! defined('WP_USER_ADMIN') ) { |
|
22 | 23 | define('WP_USER_ADMIN', false); |
24 | +} |
|
23 | 25 | |
24 | 26 | if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { |
25 | 27 | define('WP_BLOG_ADMIN', true); |
26 | 28 | } |
27 | 29 | |
28 | -if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) |
|
30 | +if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) { |
|
29 | 31 | define('WP_LOAD_IMPORTERS', true); |
32 | +} |
|
30 | 33 | |
31 | 34 | require_once(dirname(dirname(__FILE__)) . '/wp-load.php'); |
32 | 35 | |
@@ -84,8 +87,9 @@ discard block |
||
84 | 87 | auth_redirect(); |
85 | 88 | |
86 | 89 | // Schedule trash collection |
87 | -if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) |
|
90 | +if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) { |
|
88 | 91 | wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); |
92 | +} |
|
89 | 93 | |
90 | 94 | set_screen_options(); |
91 | 95 | |
@@ -120,22 +124,25 @@ discard block |
||
120 | 124 | $plugin_page = plugin_basename($plugin_page); |
121 | 125 | } |
122 | 126 | |
123 | -if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
127 | +if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) { |
|
124 | 128 | $typenow = $_REQUEST['post_type']; |
125 | -else |
|
129 | +} else { |
|
126 | 130 | $typenow = ''; |
131 | +} |
|
127 | 132 | |
128 | -if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) |
|
133 | +if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) { |
|
129 | 134 | $taxnow = $_REQUEST['taxonomy']; |
130 | -else |
|
135 | +} else { |
|
131 | 136 | $taxnow = ''; |
137 | +} |
|
132 | 138 | |
133 | -if ( WP_NETWORK_ADMIN ) |
|
139 | +if ( WP_NETWORK_ADMIN ) { |
|
134 | 140 | require(ABSPATH . 'wp-admin/network/menu.php'); |
135 | -elseif ( WP_USER_ADMIN ) |
|
141 | +} elseif ( WP_USER_ADMIN ) { |
|
136 | 142 | require(ABSPATH . 'wp-admin/user/menu.php'); |
137 | -else |
|
143 | +} else { |
|
138 | 144 | require(ABSPATH . 'wp-admin/menu.php'); |
145 | +} |
|
139 | 146 | |
140 | 147 | if ( current_user_can( 'manage_options' ) ) { |
141 | 148 | /** |
@@ -168,20 +175,22 @@ discard block |
||
168 | 175 | do_action( 'admin_init' ); |
169 | 176 | |
170 | 177 | if ( isset($plugin_page) ) { |
171 | - if ( !empty($typenow) ) |
|
172 | - $the_parent = $pagenow . '?post_type=' . $typenow; |
|
173 | - else |
|
174 | - $the_parent = $pagenow; |
|
178 | + if ( !empty($typenow) ) { |
|
179 | + $the_parent = $pagenow . '?post_type=' . $typenow; |
|
180 | + } else { |
|
181 | + $the_parent = $pagenow; |
|
182 | + } |
|
175 | 183 | if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
176 | 184 | $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
177 | 185 | |
178 | 186 | // Backwards compatibility for plugins using add_management_page(). |
179 | 187 | if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
180 | 188 | // There could be plugin specific params on the URL, so we need the whole query string |
181 | - if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
|
182 | - $query_string = $_SERVER[ 'QUERY_STRING' ]; |
|
183 | - else |
|
184 | - $query_string = 'page=' . $plugin_page; |
|
189 | + if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) { |
|
190 | + $query_string = $_SERVER[ 'QUERY_STRING' ]; |
|
191 | + } else { |
|
192 | + $query_string = 'page=' . $plugin_page; |
|
193 | + } |
|
185 | 194 | wp_redirect( admin_url('tools.php?' . $query_string) ); |
186 | 195 | exit; |
187 | 196 | } |
@@ -224,8 +233,9 @@ discard block |
||
224 | 233 | * @since 2.1.0 |
225 | 234 | */ |
226 | 235 | do_action( 'load-' . $page_hook ); |
227 | - if (! isset($_GET['noheader'])) |
|
228 | - require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
236 | + if (! isset($_GET['noheader'])) { |
|
237 | + require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
238 | + } |
|
229 | 239 | |
230 | 240 | /** |
231 | 241 | * Used to call the registered callback for a plugin screen. |
@@ -235,11 +245,13 @@ discard block |
||
235 | 245 | */ |
236 | 246 | do_action( $page_hook ); |
237 | 247 | } else { |
238 | - if ( validate_file($plugin_page) ) |
|
239 | - wp_die(__('Invalid plugin page')); |
|
248 | + if ( validate_file($plugin_page) ) { |
|
249 | + wp_die(__('Invalid plugin page')); |
|
250 | + } |
|
240 | 251 | |
241 | - if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) ) |
|
242 | - wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
|
252 | + if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) ) { |
|
253 | + wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
|
254 | + } |
|
243 | 255 | |
244 | 256 | /** |
245 | 257 | * Fires before a particular screen is loaded. |
@@ -255,13 +267,15 @@ discard block |
||
255 | 267 | */ |
256 | 268 | do_action( 'load-' . $plugin_page ); |
257 | 269 | |
258 | - if ( !isset($_GET['noheader'])) |
|
259 | - require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
270 | + if ( !isset($_GET['noheader'])) { |
|
271 | + require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
272 | + } |
|
260 | 273 | |
261 | - if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) |
|
262 | - include(WPMU_PLUGIN_DIR . "/$plugin_page"); |
|
263 | - else |
|
264 | - include(WP_PLUGIN_DIR . "/$plugin_page"); |
|
274 | + if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) { |
|
275 | + include(WPMU_PLUGIN_DIR . "/$plugin_page"); |
|
276 | + } else { |
|
277 | + include(WP_PLUGIN_DIR . "/$plugin_page"); |
|
278 | + } |
|
265 | 279 | } |
266 | 280 | |
267 | 281 | include(ABSPATH . 'wp-admin/admin-footer.php'); |
@@ -271,8 +285,9 @@ discard block |
||
271 | 285 | |
272 | 286 | $importer = $_GET['import']; |
273 | 287 | |
274 | - if ( ! current_user_can('import') ) |
|
275 | - wp_die(__('You are not allowed to import.')); |
|
288 | + if ( ! current_user_can('import') ) { |
|
289 | + wp_die(__('You are not allowed to import.')); |
|
290 | + } |
|
276 | 291 | |
277 | 292 | if ( validate_file($importer) ) { |
278 | 293 | wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
@@ -297,8 +312,9 @@ discard block |
||
297 | 312 | $submenu_file = 'import.php'; |
298 | 313 | $title = __('Import'); |
299 | 314 | |
300 | - if (! isset($_GET['noheader'])) |
|
301 | - require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
315 | + if (! isset($_GET['noheader'])) { |
|
316 | + require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
317 | + } |
|
302 | 318 | |
303 | 319 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
304 | 320 | |
@@ -346,15 +362,17 @@ discard block |
||
346 | 362 | * In all other cases, 'load-' . $pagenow should be used instead. |
347 | 363 | */ |
348 | 364 | if ( $typenow == 'page' ) { |
349 | - if ( $pagenow == 'post-new.php' ) |
|
350 | - do_action( 'load-page-new.php' ); |
|
351 | - elseif ( $pagenow == 'post.php' ) |
|
352 | - do_action( 'load-page.php' ); |
|
353 | - } elseif ( $pagenow == 'edit-tags.php' ) { |
|
354 | - if ( $taxnow == 'category' ) |
|
355 | - do_action( 'load-categories.php' ); |
|
356 | - elseif ( $taxnow == 'link_category' ) |
|
357 | - do_action( 'load-edit-link-categories.php' ); |
|
365 | + if ( $pagenow == 'post-new.php' ) { |
|
366 | + do_action( 'load-page-new.php' ); |
|
367 | + } elseif ( $pagenow == 'post.php' ) { |
|
368 | + do_action( 'load-page.php' ); |
|
369 | + } |
|
370 | + } elseif ( $pagenow == 'edit-tags.php' ) { |
|
371 | + if ( $taxnow == 'category' ) { |
|
372 | + do_action( 'load-categories.php' ); |
|
373 | + } elseif ( $taxnow == 'link_category' ) { |
|
374 | + do_action( 'load-edit-link-categories.php' ); |
|
375 | + } |
|
358 | 376 | } |
359 | 377 | } |
360 | 378 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Press This Display and Handler. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Press_This |
|
7 | - */ |
|
3 | + * Press This Display and Handler. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Press_This |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | define('IFRAME_REQUEST' , true); |
10 | 10 |
@@ -6,19 +6,19 @@ |
||
6 | 6 | * @subpackage Press_This |
7 | 7 | */ |
8 | 8 | |
9 | -define('IFRAME_REQUEST' , true); |
|
9 | +define('IFRAME_REQUEST', true); |
|
10 | 10 | |
11 | 11 | /** WordPress Administration Bootstrap */ |
12 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
12 | +require_once(dirname(__FILE__).'/admin.php'); |
|
13 | 13 | |
14 | -if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) |
|
15 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
14 | +if ( ! current_user_can('edit_posts') || ! current_user_can(get_post_type_object('post')->cap->create_posts)) |
|
15 | + wp_die(__('Cheatin’ uh?'), 403); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @global WP_Press_This $wp_press_this |
19 | 19 | */ |
20 | -if ( empty( $GLOBALS['wp_press_this'] ) ) { |
|
21 | - include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); |
|
20 | +if (empty($GLOBALS['wp_press_this'])) { |
|
21 | + include(ABSPATH.'wp-admin/includes/class-wp-press-this.php'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | $GLOBALS['wp_press_this']->html(); |
@@ -11,8 +11,9 @@ |
||
11 | 11 | /** WordPress Administration Bootstrap */ |
12 | 12 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
13 | 13 | |
14 | -if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) |
|
14 | +if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
|
15 | 15 | wp_die( __( 'Cheatin’ uh?' ), 403 ); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * @global WP_Press_This $wp_press_this |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * @subpackage Administration |
10 | 10 | */ |
11 | 11 | |
12 | -_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/admin.php' ); |
|
12 | +_deprecated_file(basename(__FILE__), '2.5', 'wp-admin/includes/admin.php'); |
|
13 | 13 | |
14 | 14 | /** WordPress Administration API: Includes all Administration functions. */ |
15 | -require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
15 | +require_once(ABSPATH.'wp-admin/includes/admin.php'); |