@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class AdminPage{ |
|
11 | +class AdminPage { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Hooks function. |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @see admin_menu, wp_ajax actions |
19 | 19 | */ |
20 | - public function hooks(){ |
|
20 | + public function hooks() { |
|
21 | 21 | |
22 | - add_action( 'admin_menu' , array( $this, 'add_menu_item' ) ); |
|
23 | - add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) ); |
|
24 | - add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) ); |
|
22 | + add_action('admin_menu', array($this, 'add_menu_item')); |
|
23 | + add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback')); |
|
24 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts')); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | |
36 | 36 | add_submenu_page( |
37 | 37 | 'tools.php', |
38 | - __( 'Create Test Data', 'evans-mu' ), |
|
39 | - __( 'Test Data', 'evans-mu' ), |
|
38 | + __('Create Test Data', 'evans-mu'), |
|
39 | + __('Test Data', 'evans-mu'), |
|
40 | 40 | 'manage_options', |
41 | 41 | 'create-test-data', |
42 | - array( $this, 'admin_page' ) |
|
42 | + array($this, 'admin_page') |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | } |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param string $hook Specific hook for the admin page that we're dealing with. |
52 | 52 | */ |
53 | - public function load_scripts( $hook ){ |
|
53 | + public function load_scripts($hook) { |
|
54 | 54 | |
55 | - wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) ); |
|
55 | + wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__))); |
|
56 | 56 | |
57 | 57 | $data = array( |
58 | - 'nonce' => wp_create_nonce( 'handle-test-data' ) |
|
58 | + 'nonce' => wp_create_nonce('handle-test-data') |
|
59 | 59 | ); |
60 | 60 | |
61 | - wp_localize_script( 'test-content-js', 'test_content', $data ); |
|
61 | + wp_localize_script('test-content-js', 'test_content', $data); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function handle_test_data_callback() { |
72 | 72 | |
73 | - $action = $_REQUEST['todo']; |
|
74 | - $nonce = $_REQUEST['nonce']; |
|
73 | + $action = $_REQUEST['todo']; |
|
74 | + $nonce = $_REQUEST['nonce']; |
|
75 | 75 | |
76 | 76 | // Verify that we have a proper logged in user and it's the right person |
77 | - if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){ |
|
77 | + if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - if ( $action == 'delete' ){ |
|
81 | + if ($action == 'delete') { |
|
82 | 82 | |
83 | - $this->deletion_routing( $_REQUEST ); |
|
83 | + $this->deletion_routing($_REQUEST); |
|
84 | 84 | |
85 | - } elseif ( $action == 'create' ){ |
|
85 | + } elseif ($action == 'create') { |
|
86 | 86 | |
87 | - $this->creation_routing( $_REQUEST ); |
|
87 | + $this->creation_routing($_REQUEST); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | * Choose which type of creation needs to be accomplished and route through |
98 | 98 | * the correct class. |
99 | 99 | */ |
100 | - private function creation_routing( $data ){ |
|
100 | + private function creation_routing($data) { |
|
101 | 101 | |
102 | - if ( $data['type'] == 'post' ){ |
|
102 | + if ($data['type'] == 'post') { |
|
103 | 103 | |
104 | 104 | $create_content = new CreatePost; |
105 | - $create_content->create_post_type_content( $data['slug'], true, 1 ); |
|
105 | + $create_content->create_post_type_content($data['slug'], true, 1); |
|
106 | 106 | |
107 | - } elseif( $data['type'] == 'term' ){ |
|
107 | + } elseif ($data['type'] == 'term') { |
|
108 | 108 | |
109 | 109 | $create_content = new CreateTerm; |
110 | - $create_content->create_terms( $data['slug'], true, 1 ); |
|
110 | + $create_content->create_terms($data['slug'], true, 1); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * Choose which type of deletion needs to be accomplished and route through |
119 | 119 | * the correct method of Delete. |
120 | 120 | */ |
121 | - private function deletion_routing( $data ){ |
|
121 | + private function deletion_routing($data) { |
|
122 | 122 | |
123 | 123 | $delete_content = new Delete; |
124 | 124 | |
125 | - if ( $data['type'] == 'post' ){ |
|
125 | + if ($data['type'] == 'post') { |
|
126 | 126 | |
127 | - $delete_content->delete_post( $data['slug'], true ); |
|
127 | + $delete_content->delete_post($data['slug'], true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * Print out our admin page to control test data. |
136 | 136 | */ |
137 | - public function admin_page(){ |
|
137 | + public function admin_page() { |
|
138 | 138 | |
139 | 139 | $html = ""; |
140 | 140 | |
141 | 141 | $html .= '<div class="wrap" id="options_editor">' . "\n"; |
142 | 142 | |
143 | - $html .= '<h2>' . __( 'Create Test Data' , 'evans-mu' ) . '</h2>' . "\n"; |
|
143 | + $html .= '<h2>' . __('Create Test Data', 'evans-mu') . '</h2>' . "\n"; |
|
144 | 144 | |
145 | 145 | // Loop through all other cpts |
146 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
146 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
147 | 147 | |
148 | 148 | $html .= "<table>"; |
149 | 149 | |
150 | - foreach ( $post_types as $post_type ) { |
|
150 | + foreach ($post_types as $post_type) { |
|
151 | 151 | |
152 | 152 | // Skip Attachments |
153 | - if ( $post_type->name == 'attachment' ){ |
|
153 | + if ($post_type->name == 'attachment') { |
|
154 | 154 | continue; |
155 | 155 | } |
156 | 156 | |
@@ -159,28 +159,28 @@ discard block |
||
159 | 159 | $html .= "<h3>"; |
160 | 160 | |
161 | 161 | $html .= "<span style='width: 20%; display: inline-block;'>" . $post_type->labels->name . "</span>"; |
162 | - $html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-plus' style='margin-top: 6px; font-size: 1.2em'></span> Create Test Data</a>"; |
|
163 | - $html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash' style='margin-top: 4px; font-size: 1.2em'></span> Delete Test Data</a>"; |
|
162 | + $html .= " <a href='javascript:void(0);' data-type='post' data-slug='" . $post_type->name . "' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-plus' style='margin-top: 6px; font-size: 1.2em'></span> Create Test Data</a>"; |
|
163 | + $html .= " <a href='javascript:void(0);' data-type='post' data-slug='" . $post_type->name . "' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash' style='margin-top: 4px; font-size: 1.2em'></span> Delete Test Data</a>"; |
|
164 | 164 | |
165 | 165 | $html .= "</h3>"; |
166 | 166 | |
167 | - $taxonomies = get_object_taxonomies( $post_type->name ); |
|
167 | + $taxonomies = get_object_taxonomies($post_type->name); |
|
168 | 168 | |
169 | - if ( !empty( $taxonomies ) ){ |
|
169 | + if (!empty($taxonomies)) { |
|
170 | 170 | |
171 | - foreach( $taxonomies as $tax ){ |
|
171 | + foreach ($taxonomies as $tax) { |
|
172 | 172 | |
173 | 173 | $html .= "<h3>"; |
174 | 174 | |
175 | - if ( $tax == 'post_format' ){ |
|
175 | + if ($tax == 'post_format') { |
|
176 | 176 | continue; |
177 | 177 | } |
178 | 178 | |
179 | - $taxonomy = get_taxonomy( $tax ); |
|
179 | + $taxonomy = get_taxonomy($tax); |
|
180 | 180 | |
181 | - $html .= "<span style='width: 20%; display: inline-block; font-size: .9em'> ".$taxonomy->labels->name."</span>"; |
|
181 | + $html .= "<span style='width: 20%; display: inline-block; font-size: .9em'> " . $taxonomy->labels->name . "</span>"; |
|
182 | 182 | |
183 | - $html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-category' style='margin-top: 4px; font-size: 1.2em'></span> Create ".$taxonomy->labels->name."</a>"; |
|
183 | + $html .= " <a href='javascript:void(0);' data-type='term' data-slug='" . $tax . "' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-category' style='margin-top: 4px; font-size: 1.2em'></span> Create " . $taxonomy->labels->name . "</a>"; |
|
184 | 184 | |
185 | 185 | $html .= "</h3>"; |
186 | 186 |