@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @subpackage Test Content |
10 | 10 | * @author Old Town Media |
11 | 11 | */ |
12 | -class Posts extends View{ |
|
12 | +class Posts extends View { |
|
13 | 13 | |
14 | 14 | protected $title = 'Posts'; |
15 | 15 | protected $type = 'post'; |
16 | - protected $priority = 1; |
|
16 | + protected $priority = 1; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Our sections action block - button to create and delete. |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return string HTML content. |
24 | 24 | */ |
25 | - protected function actions_section(){ |
|
25 | + protected function actions_section() { |
|
26 | 26 | $html = ''; |
27 | 27 | |
28 | 28 | // Loop through every post type available on the site |
29 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
29 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
30 | 30 | |
31 | - foreach ( $post_types as $post_type ) : |
|
31 | + foreach ($post_types as $post_type) : |
|
32 | 32 | |
33 | 33 | $skipped_cpts = array( |
34 | 34 | 'attachment' |
35 | 35 | ); |
36 | 36 | |
37 | 37 | // Skip banned cpts |
38 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
38 | + if (in_array($post_type->name, $skipped_cpts)) { |
|
39 | 39 | continue; |
40 | 40 | } |
41 | 41 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | |
44 | 44 | $html .= "<h3>"; |
45 | 45 | |
46 | - $html .= "<span class='label'>" . $post_type->labels->name . "</span>"; |
|
47 | - $html .= $this->build_button( 'create', $post_type->name, __( 'Create Test Data', 'otm-test-content' ) ); |
|
48 | - $html .= $this->build_button( 'delete', $post_type->name, __( 'Delete Test Data', 'otm-test-content' ) ); |
|
46 | + $html .= "<span class='label'>".$post_type->labels->name."</span>"; |
|
47 | + $html .= $this->build_button('create', $post_type->name, __('Create Test Data', 'otm-test-content')); |
|
48 | + $html .= $this->build_button('delete', $post_type->name, __('Delete Test Data', 'otm-test-content')); |
|
49 | 49 | |
50 | 50 | $html .= "</h3>"; |
51 | 51 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Various extends View{ |
|
13 | +class Various extends View { |
|
14 | 14 | |
15 | 15 | protected $title = 'Various'; |
16 | 16 | protected $type = 'all'; |
17 | - protected $priority = 3; |
|
17 | + protected $priority = 3; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string HTML content. |
26 | 26 | */ |
27 | - protected function actions_section(){ |
|
27 | + protected function actions_section() { |
|
28 | 28 | $html = ''; |
29 | 29 | |
30 | 30 | $html .= "<div class='test-data-cpt'>"; |
31 | 31 | |
32 | 32 | $html .= "<h3>"; |
33 | 33 | |
34 | - $html .= "<span class='label'>" . __( 'Clean Site', 'otm-test-content' ) . "</span>"; |
|
35 | - $html .= $this->build_button( 'delete', 'all', __( 'Delete All Test Data', 'otm-test-content' ) ); |
|
34 | + $html .= "<span class='label'>".__('Clean Site', 'otm-test-content')."</span>"; |
|
35 | + $html .= $this->build_button('delete', 'all', __('Delete All Test Data', 'otm-test-content')); |
|
36 | 36 | |
37 | 37 | $html .= "</h3>"; |
38 | 38 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $html Existing HTML content. |
51 | 51 | * @return string HTML section content. |
52 | 52 | */ |
53 | - protected function options_section( $html = '' ){ |
|
53 | + protected function options_section($html = '') { |
|
54 | 54 | return $html; |
55 | 55 | } |
56 | 56 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Terms extends View{ |
|
13 | +class Terms extends View { |
|
14 | 14 | |
15 | 15 | protected $title = 'Terms'; |
16 | 16 | protected $type = 'term'; |
17 | - protected $priority = 2; |
|
17 | + protected $priority = 2; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string HTML content. |
26 | 26 | */ |
27 | - protected function actions_section(){ |
|
27 | + protected function actions_section() { |
|
28 | 28 | $html = ''; |
29 | 29 | |
30 | 30 | $taxonomies = get_taxonomies(); |
31 | 31 | |
32 | - foreach ( $taxonomies as $tax ) : |
|
32 | + foreach ($taxonomies as $tax) : |
|
33 | 33 | |
34 | 34 | $skipped_taxonomies = array( |
35 | - 'post_format', // We shouldn't be making random post format classes |
|
36 | - 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
37 | - 'nav_menu', // Menus are handled seperately of taxonomies |
|
35 | + 'post_format', // We shouldn't be making random post format classes |
|
36 | + 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
37 | + 'nav_menu', // Menus are handled seperately of taxonomies |
|
38 | 38 | ); |
39 | 39 | |
40 | 40 | // Skip banned taxonomies |
41 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
41 | + if (in_array($tax, $skipped_taxonomies)) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
45 | - $taxonomy = get_taxonomy( $tax ); |
|
45 | + $taxonomy = get_taxonomy($tax); |
|
46 | 46 | |
47 | 47 | $html .= "<div class='test-data-cpt'>"; |
48 | 48 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $html .= "<span class='label'>".$taxonomy->labels->name."</span>"; |
52 | 52 | |
53 | - $html .= $this->build_button( 'create', $tax, __( 'Create', 'otm-test-content' )." ".$taxonomy->labels->name ); |
|
54 | - $html .= $this->build_button( 'delete', $tax, __( 'Delete', 'otm-test-content' )." ".$taxonomy->labels->name ); |
|
53 | + $html .= $this->build_button('create', $tax, __('Create', 'otm-test-content')." ".$taxonomy->labels->name); |
|
54 | + $html .= $this->build_button('delete', $tax, __('Delete', 'otm-test-content')." ".$taxonomy->labels->name); |
|
55 | 55 | |
56 | 56 | $html .= "</h3>"; |
57 | 57 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -abstract class View{ |
|
13 | +abstract class View { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * title |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @see tab, view |
46 | 46 | */ |
47 | - public function register_view(){ |
|
47 | + public function register_view() { |
|
48 | 48 | |
49 | - add_action( 'tc-admin-tabs', array( $this, 'tab' ), $this->priority ); |
|
50 | - add_action( 'tc-admin-sections', array( $this, 'view' ), $this->priority ); |
|
49 | + add_action('tc-admin-tabs', array($this, 'tab'), $this->priority); |
|
50 | + add_action('tc-admin-sections', array($this, 'view'), $this->priority); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Each view has a tab and tab navigation - this function compiles our |
59 | 59 | * navigation tab. Rarely extended. |
60 | 60 | */ |
61 | - public function tab(){ |
|
61 | + public function tab() { |
|
62 | 62 | $html = ""; |
63 | 63 | |
64 | 64 | $html .= "<a class='nav-tab' href='javascript:void(0)'>"; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @see actions_section, options_section |
80 | 80 | */ |
81 | - public function view(){ |
|
81 | + public function view() { |
|
82 | 82 | $html = ''; |
83 | 83 | |
84 | 84 | $html .= "<section class='test-content-tab'>"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return string HTML content. |
100 | 100 | */ |
101 | - protected function actions_section(){ |
|
101 | + protected function actions_section() { |
|
102 | 102 | $html = ''; |
103 | 103 | return $html; |
104 | 104 | } |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | * @param string $html Existing HTML content. |
116 | 116 | * @return string HTML section content. |
117 | 117 | */ |
118 | - protected function options_section( $html = '' ){ |
|
118 | + protected function options_section($html = '') { |
|
119 | 119 | $html .= "<div class='test-data-cpt'>"; |
120 | 120 | $html .= "<h3>"; |
121 | - $html .= "<span class='label'>".__( 'Quantity', 'otm-test-content' )."</span>"; |
|
122 | - $html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' placeholder='".__( '', 'otm-test-content' )."'> "; |
|
121 | + $html .= "<span class='label'>".__('Quantity', 'otm-test-content')."</span>"; |
|
122 | + $html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' placeholder='".__('', 'otm-test-content')."'> "; |
|
123 | 123 | $html .= "</h3>"; |
124 | 124 | $html .= "</div>"; |
125 | 125 | |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | * @param string $text Text to display in the button. |
138 | 138 | * @return string HTML. |
139 | 139 | */ |
140 | - protected function build_button( $action, $slug, $text ){ |
|
140 | + protected function build_button($action, $slug, $text) { |
|
141 | 141 | $html = $dashicon = ''; |
142 | 142 | |
143 | - if ( $action == 'create' ){ |
|
143 | + if ($action == 'create') { |
|
144 | 144 | $dashicon = 'dashicons-plus'; |
145 | - } elseif ( $action == 'delete' ){ |
|
145 | + } elseif ($action == 'delete') { |
|
146 | 146 | $dashicon = 'dashicons-trash'; |
147 | 147 | } |
148 | 148 | |
149 | 149 | $html .= "<a href='javascript:void(0);' "; |
150 | - $html .= " data-type='" . $this->type . "'"; |
|
151 | - $html .= " data-slug='" . $slug . "'"; |
|
152 | - $html .= " data-todo='" . $action . "'"; |
|
150 | + $html .= " data-type='".$this->type."'"; |
|
151 | + $html .= " data-slug='".$slug."'"; |
|
152 | + $html .= " data-todo='".$action."'"; |
|
153 | 153 | $html .= " class='button-primary handle-test-data'"; |
154 | 154 | $html .= "/>"; |
155 | - $html .= "<span class='dashicons " . $dashicon . "'></span>"; |
|
155 | + $html .= "<span class='dashicons ".$dashicon."'></span>"; |
|
156 | 156 | $html .= $text; |
157 | 157 | $html .= "</a>"; |
158 | 158 |
@@ -21,30 +21,30 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param string $class Class name. |
23 | 23 | */ |
24 | -function test_content_autoloader( $class ) { |
|
25 | - $namespace = explode( '\\', $class ); |
|
24 | +function test_content_autoloader($class) { |
|
25 | + $namespace = explode('\\', $class); |
|
26 | 26 | |
27 | - if ( __NAMESPACE__ !== $namespace[0] ){ |
|
27 | + if (__NAMESPACE__ !== $namespace[0]) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | - $class = str_replace( __NAMESPACE__ . '\\', '', $class ); |
|
31 | + $class = str_replace(__NAMESPACE__.'\\', '', $class); |
|
32 | 32 | |
33 | 33 | |
34 | - if ( 'Views' === $namespace[1] ){ |
|
35 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
36 | - $class = str_replace( '\\', '', $class ); |
|
37 | - $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
34 | + if ('Views' === $namespace[1]) { |
|
35 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '/\1', $class)); |
|
36 | + $class = str_replace('\\', '', $class); |
|
37 | + $file = dirname(__FILE__).'/'.$class.'.php'; |
|
38 | 38 | } else { |
39 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
40 | - $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
39 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class)); |
|
40 | + $file = dirname(__FILE__).'/includes/class-'.$class.'.php'; |
|
41 | 41 | } |
42 | 42 | |
43 | - if ( file_exists( $file ) ) { |
|
44 | - require_once( $file ); |
|
43 | + if (file_exists($file)) { |
|
44 | + require_once($file); |
|
45 | 45 | } |
46 | 46 | } |
47 | - spl_autoload_register( __NAMESPACE__ . '\test_content_autoloader' ); |
|
47 | + spl_autoload_register(__NAMESPACE__.'\test_content_autoloader'); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | function plugin() { |
57 | 57 | static $instance; |
58 | 58 | |
59 | - if ( null === $instance ) { |
|
59 | + if (null === $instance) { |
|
60 | 60 | $instance = new Plugin(); |
61 | 61 | } |
62 | 62 | |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | // Set our definitions for later use |
67 | 67 | plugin()->set_definitions( |
68 | 68 | (object) array( |
69 | - 'basename' => plugin_basename( __FILE__ ), |
|
70 | - 'directory' => plugin_dir_path( __FILE__ ), |
|
69 | + 'basename' => plugin_basename(__FILE__), |
|
70 | + 'directory' => plugin_dir_path(__FILE__), |
|
71 | 71 | 'file' => __FILE__, |
72 | 72 | 'slug' => 'structure', |
73 | - 'url' => plugin_dir_url( __FILE__ ) |
|
73 | + 'url' => plugin_dir_url(__FILE__) |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | |
77 | 77 | // Register hook providers and views. |
78 | - plugin()->register_hooks( new AdminPage() ) |
|
79 | - ->register_views( new Views\Posts() ) |
|
80 | - ->register_views( new Views\Terms() ) |
|
81 | - ->register_views( new Views\Various() ); |
|
78 | + plugin()->register_hooks(new AdminPage()) |
|
79 | + ->register_views(new Views\Posts()) |
|
80 | + ->register_views(new Views\Terms()) |
|
81 | + ->register_views(new Views\Various()); |
|
82 | 82 | |
83 | 83 | // Load textdomain hook |
84 | -add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) ); |
|
84 | +add_action('plugins_loaded', array(plugin(), 'load_textdomain')); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Plugin{ |
|
11 | +class Plugin { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Plugin definitions. |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param object $definitions Information about the plugin |
35 | 35 | * @return object $this |
36 | 36 | */ |
37 | - public function set_definitions( $definitions ) { |
|
37 | + public function set_definitions($definitions) { |
|
38 | 38 | |
39 | 39 | $this->definitions = $definitions; |
40 | 40 | return $this; |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param object $provider Hook provider. |
49 | 49 | * @return object $this |
50 | 50 | */ |
51 | - public function register_hooks( $provider ) { |
|
51 | + public function register_hooks($provider) { |
|
52 | 52 | |
53 | - if ( method_exists( $provider, 'set_plugin' ) ) { |
|
54 | - $provider->set_plugin( $this ); |
|
53 | + if (method_exists($provider, 'set_plugin')) { |
|
54 | + $provider->set_plugin($this); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $provider->hooks(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param object $provider Hook provider. |
67 | 67 | * @return object $this |
68 | 68 | */ |
69 | - public function register_views( $provider ) { |
|
69 | + public function register_views($provider) { |
|
70 | 70 | |
71 | 71 | $provider->register_view(); |
72 | 72 | return $this; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @see load_plugin_textdomain |
81 | 81 | */ |
82 | 82 | public function load_textdomain() { |
83 | - load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' ); |
|
83 | + load_plugin_textdomain('otm-test-content', FALSE, basename(dirname($this->definitions->file)).'/languages/'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | } |
@@ -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 | * plugin |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @see admin_menu, wp_ajax actions |
47 | 47 | */ |
48 | - public function hooks(){ |
|
48 | + public function hooks() { |
|
49 | 49 | |
50 | 50 | $connection = new ConnectionTest; |
51 | - $this->definitions = $this->plugin->get_definitions(); |
|
52 | - $this->connected = $connection->test(); |
|
51 | + $this->definitions = $this->plugin->get_definitions(); |
|
52 | + $this->connected = $connection->test(); |
|
53 | 53 | |
54 | - add_action( 'admin_menu' , array( $this, 'add_menu_item' ) ); |
|
55 | - add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) ); |
|
56 | - add_filter( 'plugin_action_links_' . $this->definitions->basename , array( $this, 'add_settings_link' ) ); |
|
57 | - add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) ); |
|
54 | + add_action('admin_menu', array($this, 'add_menu_item')); |
|
55 | + add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback')); |
|
56 | + add_filter('plugin_action_links_'.$this->definitions->basename, array($this, 'add_settings_link')); |
|
57 | + add_action('admin_notices', array($this, 'internet_connected_admin_notice')); |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param Plugin $plugin Main plugin instance. |
66 | 66 | */ |
67 | - public function set_plugin( $plugin ) { |
|
67 | + public function set_plugin($plugin) { |
|
68 | 68 | |
69 | 69 | $this->plugin = $plugin; |
70 | 70 | return $this; |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | |
82 | 82 | $page = add_submenu_page( |
83 | 83 | 'tools.php', |
84 | - __( 'Create Test Content', 'otm-test-content' ), |
|
85 | - __( 'Test Content', 'otm-test-content' ), |
|
84 | + __('Create Test Content', 'otm-test-content'), |
|
85 | + __('Test Content', 'otm-test-content'), |
|
86 | 86 | 'manage_options', |
87 | 87 | 'create-test-data', |
88 | - array( $this, 'admin_page' ) |
|
88 | + array($this, 'admin_page') |
|
89 | 89 | ); |
90 | 90 | |
91 | - add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) ); |
|
91 | + add_action('admin_print_styles-'.$page, array($this, 'load_scripts')); |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @param array $links Existing links |
99 | 99 | * @return array Modified links |
100 | 100 | */ |
101 | - public function add_settings_link( $links ) { |
|
101 | + public function add_settings_link($links) { |
|
102 | 102 | |
103 | - $settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'otm-test-content' ) . '</a>'; |
|
104 | - array_push( $links, $settings_link ); |
|
103 | + $settings_link = '<a href="tools.php?page=create-test-data">'.__('Build Test Content', 'otm-test-content').'</a>'; |
|
104 | + array_push($links, $settings_link); |
|
105 | 105 | return $links; |
106 | 106 | |
107 | 107 | } |
@@ -114,24 +114,24 @@ discard block |
||
114 | 114 | * Internet, and the test fails displays a notice informing the user that |
115 | 115 | * images will not pull into test data. |
116 | 116 | */ |
117 | - public function internet_connected_admin_notice(){ |
|
117 | + public function internet_connected_admin_notice() { |
|
118 | 118 | |
119 | 119 | // Get the current admin screen & verify that we're on the right one |
120 | 120 | // before continuing. |
121 | 121 | $screen = get_current_screen(); |
122 | 122 | |
123 | - if ( $screen->base != 'tools_page_create-test-data' ){ |
|
123 | + if ($screen->base != 'tools_page_create-test-data') { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Check the response |
128 | - if ( $this->connected ) { |
|
128 | + if ($this->connected) { |
|
129 | 129 | // We got a response so early return |
130 | 130 | return; |
131 | 131 | } else { |
132 | 132 | // We didn't get a reponse so print the notice out |
133 | 133 | echo '<div class="notice notice-error">'; |
134 | - echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>'; |
|
134 | + echo '<p>'.__('WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content').'</p>'; |
|
135 | 135 | echo '</div>'; |
136 | 136 | } |
137 | 137 | |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * Load our script in the admin section and serve in data. |
143 | 143 | */ |
144 | - public function load_scripts(){ |
|
144 | + public function load_scripts() { |
|
145 | 145 | |
146 | - wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) ); |
|
147 | - wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) ); |
|
146 | + wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__))); |
|
147 | + wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__))); |
|
148 | 148 | |
149 | 149 | $data = array( |
150 | - 'nonce' => wp_create_nonce( 'handle-test-data' ), |
|
151 | - 'createdStr' => __( 'Created', 'otm-test-content' ), |
|
152 | - 'deletedStr' => __( 'Deleting', 'otm-test-content' ), |
|
153 | - 'creatingStr' => __( 'Creating', 'otm-test-content' ), |
|
150 | + 'nonce' => wp_create_nonce('handle-test-data'), |
|
151 | + 'createdStr' => __('Created', 'otm-test-content'), |
|
152 | + 'deletedStr' => __('Deleting', 'otm-test-content'), |
|
153 | + 'creatingStr' => __('Creating', 'otm-test-content'), |
|
154 | 154 | ); |
155 | 155 | |
156 | - wp_localize_script( 'test-content-js', 'test_content', $data ); |
|
156 | + wp_localize_script('test-content-js', 'test_content', $data); |
|
157 | 157 | |
158 | 158 | } |
159 | 159 | |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function handle_test_data_callback() { |
167 | 167 | |
168 | - $action = $_REQUEST['todo']; |
|
169 | - $nonce = $_REQUEST['nonce']; |
|
168 | + $action = $_REQUEST['todo']; |
|
169 | + $nonce = $_REQUEST['nonce']; |
|
170 | 170 | |
171 | 171 | // Verify that we have a proper logged in user and it's the right person |
172 | - if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){ |
|
172 | + if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | - if ( $action == 'delete' ){ |
|
176 | + if ($action == 'delete') { |
|
177 | 177 | |
178 | - $this->deletion_routing( $_REQUEST ); |
|
178 | + $this->deletion_routing($_REQUEST); |
|
179 | 179 | |
180 | - } elseif ( $action == 'create' ){ |
|
180 | + } elseif ($action == 'create') { |
|
181 | 181 | |
182 | - $this->creation_routing( $_REQUEST ); |
|
182 | + $this->creation_routing($_REQUEST); |
|
183 | 183 | |
184 | 184 | } |
185 | 185 | |
@@ -192,17 +192,17 @@ discard block |
||
192 | 192 | * Choose which type of creation needs to be accomplished and route through |
193 | 193 | * the correct class. |
194 | 194 | */ |
195 | - private function creation_routing( $data ){ |
|
195 | + private function creation_routing($data) { |
|
196 | 196 | |
197 | - if ( $data['type'] == 'post' ){ |
|
197 | + if ($data['type'] == 'post') { |
|
198 | 198 | |
199 | 199 | $create_content = new CreatePost; |
200 | - $create_content->create_post_type_content( $data['slug'], $data['connection'], true, 1 ); |
|
200 | + $create_content->create_post_type_content($data['slug'], $data['connection'], true, 1); |
|
201 | 201 | |
202 | - } elseif( $data['type'] == 'term' ){ |
|
202 | + } elseif ($data['type'] == 'term') { |
|
203 | 203 | |
204 | 204 | $create_content = new CreateTerm; |
205 | - $create_content->create_terms( $data['slug'], true, 1 ); |
|
205 | + $create_content->create_terms($data['slug'], true, 1); |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
@@ -213,21 +213,21 @@ discard block |
||
213 | 213 | * Choose which type of deletion needs to be accomplished and route through |
214 | 214 | * the correct method of Delete. |
215 | 215 | */ |
216 | - private function deletion_routing( $data ){ |
|
216 | + private function deletion_routing($data) { |
|
217 | 217 | |
218 | 218 | $delete_content = new Delete; |
219 | 219 | |
220 | - if ( $data['type'] == 'post' ){ |
|
220 | + if ($data['type'] == 'post') { |
|
221 | 221 | |
222 | - $delete_content->delete_posts( $data['slug'], true ); |
|
222 | + $delete_content->delete_posts($data['slug'], true); |
|
223 | 223 | |
224 | - } elseif ( $data['type'] == 'term' ){ |
|
224 | + } elseif ($data['type'] == 'term') { |
|
225 | 225 | |
226 | - $delete_content->delete_terms( $data['slug'], true ); |
|
226 | + $delete_content->delete_terms($data['slug'], true); |
|
227 | 227 | |
228 | - } elseif ( $data['type'] == 'all' ){ |
|
228 | + } elseif ($data['type'] == 'all') { |
|
229 | 229 | |
230 | - $delete_content->delete_all_test_data( true ); |
|
230 | + $delete_content->delete_all_test_data(true); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -237,20 +237,20 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * Print out our admin page to control test data. |
239 | 239 | */ |
240 | - public function admin_page(){ |
|
241 | - echo '<div class="wrap" id="options_editor">' . "\n"; |
|
240 | + public function admin_page() { |
|
241 | + echo '<div class="wrap" id="options_editor">'."\n"; |
|
242 | 242 | |
243 | - echo '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n"; |
|
243 | + echo '<h2>'.__('Create Test Data', 'otm-test-content').'</h2>'."\n"; |
|
244 | 244 | |
245 | 245 | echo "<div class='nav-tab-wrapper'>"; |
246 | 246 | |
247 | - do_action( 'tc-admin-tabs', '' ); |
|
247 | + do_action('tc-admin-tabs', ''); |
|
248 | 248 | |
249 | 249 | echo "</div>"; |
250 | 250 | |
251 | 251 | echo ""; |
252 | 252 | |
253 | - do_action( 'tc-admin-sections', '' ); |
|
253 | + do_action('tc-admin-sections', ''); |
|
254 | 254 | |
255 | 255 | echo ""; |
256 | 256 |
@@ -8,32 +8,32 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Delete{ |
|
11 | +class Delete { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Delete all test content created ever. |
15 | 15 | * |
16 | 16 | * @access private |
17 | 17 | */ |
18 | - public function delete_all_test_data( $echo = false ){ |
|
18 | + public function delete_all_test_data($echo = false) { |
|
19 | 19 | |
20 | - if ( !$this->user_can_delete() ){ |
|
20 | + if (!$this->user_can_delete()) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
24 | 24 | // Loop through all post types and remove any test data |
25 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
26 | - foreach ( $post_types as $post_type ) : |
|
25 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
26 | + foreach ($post_types as $post_type) : |
|
27 | 27 | |
28 | - $this->delete_posts( $post_type->name, $echo ); |
|
28 | + $this->delete_posts($post_type->name, $echo); |
|
29 | 29 | |
30 | 30 | endforeach; |
31 | 31 | |
32 | 32 | // Loop through all taxonomies and remove any data |
33 | 33 | $taxonomies = get_taxonomies(); |
34 | - foreach ( $taxonomies as $tax ) : |
|
34 | + foreach ($taxonomies as $tax) : |
|
35 | 35 | |
36 | - $this->delete_terms( $tax, $echo ); |
|
36 | + $this->delete_terms($tax, $echo); |
|
37 | 37 | |
38 | 38 | endforeach; |
39 | 39 | |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * @param string $slug a custom post type ID. |
53 | 53 | * @param boolean $echo Whether or not to echo the result |
54 | 54 | */ |
55 | - public function delete_posts( $slug, $echo = false ){ |
|
55 | + public function delete_posts($slug, $echo = false) { |
|
56 | 56 | |
57 | 57 | // Make sure that the current user is logged in & has full permissions. |
58 | - if ( !$this->user_can_delete() ){ |
|
58 | + if (!$this->user_can_delete()) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Check that $cptslg has a string. |
63 | - if ( empty( $slug ) ){ |
|
63 | + if (empty($slug)) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
@@ -77,39 +77,39 @@ discard block |
||
77 | 77 | ), |
78 | 78 | ); |
79 | 79 | |
80 | - $objects = new \WP_Query( $query ); |
|
80 | + $objects = new \WP_Query($query); |
|
81 | 81 | |
82 | - if ( $objects->have_posts() ){ |
|
82 | + if ($objects->have_posts()) { |
|
83 | 83 | |
84 | 84 | $events = array(); |
85 | 85 | |
86 | - while ( $objects->have_posts() ) : $objects->the_post(); |
|
86 | + while ($objects->have_posts()) : $objects->the_post(); |
|
87 | 87 | |
88 | 88 | // Find any media associated with the test post and delete it as well |
89 | - $this->delete_associated_media( get_the_id() ); |
|
89 | + $this->delete_associated_media(get_the_id()); |
|
90 | 90 | |
91 | - if ( $echo === true ){ |
|
91 | + if ($echo === true) { |
|
92 | 92 | $events[] = array( |
93 | 93 | 'type' => 'deleted', |
94 | 94 | 'pid' => get_the_id(), |
95 | - 'post_type' => get_post_type( get_the_id() ), |
|
95 | + 'post_type' => get_post_type(get_the_id()), |
|
96 | 96 | 'link' => '' |
97 | 97 | ); |
98 | 98 | } |
99 | 99 | |
100 | 100 | // Force delete the post |
101 | - wp_delete_post( get_the_id(), true ); |
|
101 | + wp_delete_post(get_the_id(), true); |
|
102 | 102 | |
103 | 103 | endwhile; |
104 | 104 | |
105 | - $obj = get_post_type_object( $slug ); |
|
105 | + $obj = get_post_type_object($slug); |
|
106 | 106 | |
107 | 107 | $events[] = array( |
108 | 108 | 'type' => 'general', |
109 | - 'message' => __( 'Deleted', 'otm-test-content' ) . ' ' . $obj->labels->all_items |
|
109 | + 'message' => __('Deleted', 'otm-test-content').' '.$obj->labels->all_items |
|
110 | 110 | ); |
111 | 111 | |
112 | - echo \json_encode( $events ); |
|
112 | + echo \json_encode($events); |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
@@ -129,26 +129,26 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @param int $pid a custom post type ID. |
131 | 131 | */ |
132 | - private function delete_associated_media( $pid ){ |
|
132 | + private function delete_associated_media($pid) { |
|
133 | 133 | |
134 | 134 | // Make sure that the current user is logged in & has full permissions. |
135 | - if ( !$this->user_can_delete() ){ |
|
135 | + if (!$this->user_can_delete()) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Make sure $pid is, in fact, an ID |
140 | - if ( !is_int( $pid ) ){ |
|
140 | + if (!is_int($pid)) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | 144 | // Get our images |
145 | - $media = get_attached_media( 'image', $pid ); |
|
145 | + $media = get_attached_media('image', $pid); |
|
146 | 146 | |
147 | - if ( !empty( $media ) ){ |
|
147 | + if (!empty($media)) { |
|
148 | 148 | |
149 | 149 | // Loop through the media & delete each one |
150 | - foreach ( $media as $attachment ){ |
|
151 | - wp_delete_attachment( $attachment->ID, true ); |
|
150 | + foreach ($media as $attachment) { |
|
151 | + wp_delete_attachment($attachment->ID, true); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | } |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | * @param string $slug a custom post type ID. |
169 | 169 | * @param boolean $echo Whether or not to echo the result |
170 | 170 | */ |
171 | - public function delete_terms( $slug, $echo = false ){ |
|
171 | + public function delete_terms($slug, $echo = false) { |
|
172 | 172 | |
173 | 173 | // Make sure that the current user is logged in & has full permissions. |
174 | - if ( !$this->user_can_delete() ){ |
|
174 | + if (!$this->user_can_delete()) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | 178 | // Check that $cptslg has a string. |
179 | - if ( empty( $slug ) ){ |
|
179 | + if (empty($slug)) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | ) |
193 | 193 | ); |
194 | 194 | |
195 | - $terms = get_terms( $slug, $args ); |
|
195 | + $terms = get_terms($slug, $args); |
|
196 | 196 | |
197 | - if ( !empty( $terms ) ){ |
|
197 | + if (!empty($terms)) { |
|
198 | 198 | |
199 | 199 | $events = array(); |
200 | 200 | |
201 | - foreach ( $terms as $term ){ |
|
201 | + foreach ($terms as $term) { |
|
202 | 202 | |
203 | - if ( $echo === true ){ |
|
203 | + if ($echo === true) { |
|
204 | 204 | $events[] = array( |
205 | 205 | 'type' => 'deleted', |
206 | 206 | 'pid' => $term->term_id, |
@@ -210,18 +210,18 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | // Delete our term |
213 | - wp_delete_term( $term->term_id, $slug ); |
|
213 | + wp_delete_term($term->term_id, $slug); |
|
214 | 214 | |
215 | 215 | } |
216 | 216 | |
217 | - $taxonomy = get_taxonomy( $slug ); |
|
217 | + $taxonomy = get_taxonomy($slug); |
|
218 | 218 | |
219 | 219 | $events[] = array( |
220 | 220 | 'type' => 'general', |
221 | - 'message' => __( 'Deleted', 'otm-test-content' ) . ' ' . $taxonomy->labels->name |
|
221 | + 'message' => __('Deleted', 'otm-test-content').' '.$taxonomy->labels->name |
|
222 | 222 | ); |
223 | 223 | |
224 | - echo \json_encode( $events ); |
|
224 | + echo \json_encode($events); |
|
225 | 225 | |
226 | 226 | } |
227 | 227 | |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @see is_user_logged_in, current_user_can |
235 | 235 | */ |
236 | - private function user_can_delete(){ |
|
236 | + private function user_can_delete() { |
|
237 | 237 | |
238 | 238 | // User must be logged in |
239 | - if ( !is_user_logged_in() ){ |
|
239 | + if (!is_user_logged_in()) { |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
243 | 243 | // User must have editor priveledges, at a minimum |
244 | - if ( !current_user_can( 'delete_others_posts' ) ){ |
|
244 | + if (!current_user_can('delete_others_posts')) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class CreatePost{ |
|
11 | +class CreatePost { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * metaboxes |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @see Metaboxes |
27 | 27 | */ |
28 | - public function __construct(){ |
|
28 | + public function __construct() { |
|
29 | 29 | |
30 | 30 | $this->metaboxes = new Metaboxes; |
31 | 31 | |
@@ -47,32 +47,32 @@ discard block |
||
47 | 47 | * @param boolean $echo Whether or not to echo. Optional. |
48 | 48 | * @param int $num Optional. Number of posts to create. |
49 | 49 | */ |
50 | - public function create_post_type_content( $slug, $connection, $echo = false, $num = '' ){ |
|
50 | + public function create_post_type_content($slug, $connection, $echo = false, $num = '') { |
|
51 | 51 | |
52 | 52 | // If we're missing a custom post type id - don't do anything |
53 | - if ( empty( $slug ) ){ |
|
53 | + if (empty($slug)) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Gather the necessary data to create the posts |
58 | - $supports = $this->get_cpt_supports( $slug ); |
|
59 | - $metaboxes = $this->metaboxes->get_metaboxes( $slug ); |
|
58 | + $supports = $this->get_cpt_supports($slug); |
|
59 | + $metaboxes = $this->metaboxes->get_metaboxes($slug); |
|
60 | 60 | |
61 | 61 | // Set our connection status for the rest of the methods |
62 | 62 | $this->connected = $connection; |
63 | 63 | |
64 | 64 | // If we forgot to put in a quantity, make one for us |
65 | - if ( empty( $num ) ){ |
|
66 | - $num = rand( 5, 30 ); |
|
65 | + if (empty($num)) { |
|
66 | + $num = rand(5, 30); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Create test posts |
70 | - for( $i = 0; $i < $num; $i++ ){ |
|
70 | + for ($i = 0; $i < $num; $i++) { |
|
71 | 71 | |
72 | - $return = $this->create_test_object( $slug, $supports, $metaboxes ); |
|
72 | + $return = $this->create_test_object($slug, $supports, $metaboxes); |
|
73 | 73 | |
74 | - if ( $echo === true ){ |
|
75 | - echo \json_encode( $return ); |
|
74 | + if ($echo === true) { |
|
75 | + echo \json_encode($return); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | * @param array $supports Features that the post type supports. |
96 | 96 | * @param array $supports All CMB2 metaboxes attached to the post type. |
97 | 97 | */ |
98 | - private function create_test_object( $slug, $supports, $metaboxes ){ |
|
98 | + private function create_test_object($slug, $supports, $metaboxes) { |
|
99 | 99 | $return = ''; |
100 | 100 | |
101 | 101 | // Get a random title |
102 | - $title = apply_filters( "tc_{$slug}_post_title", TestContent::title() ); |
|
102 | + $title = apply_filters("tc_{$slug}_post_title", TestContent::title()); |
|
103 | 103 | |
104 | 104 | // First, insert our post |
105 | 105 | $post = array( |
106 | - 'post_name' => sanitize_title( $title ), |
|
106 | + 'post_name' => sanitize_title($title), |
|
107 | 107 | 'post_status' => 'publish', |
108 | 108 | 'post_type' => $slug, |
109 | 109 | 'ping_status' => 'closed', |
@@ -111,57 +111,57 @@ discard block |
||
111 | 111 | ); |
112 | 112 | |
113 | 113 | // Add title if supported |
114 | - if ( $supports['title'] === true ){ |
|
114 | + if ($supports['title'] === true) { |
|
115 | 115 | $post['post_title'] = $title; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Add main content if supported |
119 | - if ( $supports['editor'] === true ){ |
|
120 | - $post['post_content'] = apply_filters( "tc_{$slug}_post_content", TestContent::paragraphs() ); |
|
119 | + if ($supports['editor'] === true) { |
|
120 | + $post['post_content'] = apply_filters("tc_{$slug}_post_content", TestContent::paragraphs()); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Add excerpt content if supported |
124 | - if ( $supports['excerpt'] === true ){ |
|
125 | - $post['post_excerpt'] = apply_filters( "tc_{$slug}_post_excerpt", TestContent::plain_text() ); |
|
124 | + if ($supports['excerpt'] === true) { |
|
125 | + $post['post_excerpt'] = apply_filters("tc_{$slug}_post_excerpt", TestContent::plain_text()); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Insert then post object |
129 | - $post_id = wp_insert_post( apply_filters( "tc_{$slug}_post_arguments", $post ) ); |
|
129 | + $post_id = wp_insert_post(apply_filters("tc_{$slug}_post_arguments", $post)); |
|
130 | 130 | |
131 | 131 | // Then, set a test content flag on the new post for later deletion |
132 | - add_post_meta( $post_id, 'evans_test_content', '__test__', true ); |
|
132 | + add_post_meta($post_id, 'evans_test_content', '__test__', true); |
|
133 | 133 | |
134 | 134 | // Add thumbnail if supported |
135 | - if ( $this->connected == true && ( $supports['thumbnail'] === true || in_array( $slug, array( 'post', 'page' ) ) ) ){ |
|
136 | - update_post_meta( $post_id, '_thumbnail_id', TestContent::image( $post_id ) ); |
|
135 | + if ($this->connected == true && ($supports['thumbnail'] === true || in_array($slug, array('post', 'page')))) { |
|
136 | + update_post_meta($post_id, '_thumbnail_id', TestContent::image($post_id)); |
|
137 | 137 | } |
138 | 138 | |
139 | - $taxonomies = get_object_taxonomies( $slug ); |
|
139 | + $taxonomies = get_object_taxonomies($slug); |
|
140 | 140 | |
141 | 141 | // Assign the post to terms |
142 | - if ( !empty( $taxonomies ) ){ |
|
143 | - $return .= $this->assign_terms( $post_id, $taxonomies ); |
|
142 | + if (!empty($taxonomies)) { |
|
143 | + $return .= $this->assign_terms($post_id, $taxonomies); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // Spin up metaboxes |
147 | - if ( !empty( $metaboxes ) ){ |
|
148 | - foreach ( $metaboxes as $cmb ) : |
|
149 | - $return .= $this->metaboxes->random_metabox_content( $post_id, $cmb, $this->connected ); |
|
147 | + if (!empty($metaboxes)) { |
|
148 | + foreach ($metaboxes as $cmb) : |
|
149 | + $return .= $this->metaboxes->random_metabox_content($post_id, $cmb, $this->connected); |
|
150 | 150 | endforeach; |
151 | 151 | } |
152 | 152 | |
153 | 153 | // Check if we have errors and return them or created message |
154 | - if ( is_wp_error( $return ) ){ |
|
155 | - error_log( $return->get_error_message() ); |
|
154 | + if (is_wp_error($return)) { |
|
155 | + error_log($return->get_error_message()); |
|
156 | 156 | return $return; |
157 | 157 | } else { |
158 | 158 | return array( |
159 | 159 | 'type' => 'created', |
160 | 160 | 'object' => 'post', |
161 | 161 | 'pid' => $post_id, |
162 | - 'post_type' => get_post_type( $post_id ), |
|
163 | - 'link_edit' => admin_url( '/post.php?post='.$post_id.'&action=edit' ), |
|
164 | - 'link_view' => get_permalink( $post_id ), |
|
162 | + 'post_type' => get_post_type($post_id), |
|
163 | + 'link_edit' => admin_url('/post.php?post='.$post_id.'&action=edit'), |
|
164 | + 'link_view' => get_permalink($post_id), |
|
165 | 165 | ); |
166 | 166 | } |
167 | 167 | |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | * @param string $slug a custom post type ID. |
179 | 179 | * @return array Array of necessary supports booleans. |
180 | 180 | */ |
181 | - private function get_cpt_supports( $slug ){ |
|
181 | + private function get_cpt_supports($slug) { |
|
182 | 182 | |
183 | 183 | $supports = array( |
184 | - 'title' => post_type_supports( $slug, 'title' ), |
|
185 | - 'editor' => post_type_supports( $slug, 'editor' ), |
|
186 | - 'excerpt' => post_type_supports( $slug, 'excerpt' ), |
|
187 | - 'thumbnail' => post_type_supports( $slug, 'thumbnail' ) |
|
184 | + 'title' => post_type_supports($slug, 'title'), |
|
185 | + 'editor' => post_type_supports($slug, 'editor'), |
|
186 | + 'excerpt' => post_type_supports($slug, 'excerpt'), |
|
187 | + 'thumbnail' => post_type_supports($slug, 'thumbnail') |
|
188 | 188 | ); |
189 | 189 | |
190 | 190 | return $supports; |
@@ -205,26 +205,26 @@ discard block |
||
205 | 205 | * @param array $taxonomies taxonomies assigned to this cpt. |
206 | 206 | * @return object WP Error if there is one. |
207 | 207 | */ |
208 | - private function assign_terms( $post_id, $taxonomies ){ |
|
208 | + private function assign_terms($post_id, $taxonomies) { |
|
209 | 209 | |
210 | 210 | // Make sure it's an array & has items |
211 | - if ( empty( $taxonomies ) || !is_array( $taxonomies ) ){ |
|
211 | + if (empty($taxonomies) || !is_array($taxonomies)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
215 | - foreach ( $taxonomies as $tax ){ |
|
215 | + foreach ($taxonomies as $tax) { |
|
216 | 216 | |
217 | 217 | // Get the individual terms already existing |
218 | - $terms = get_terms( $tax, array( 'hide_empty' => false ) ); |
|
219 | - $count = count( $terms ) - 1; |
|
218 | + $terms = get_terms($tax, array('hide_empty' => false)); |
|
219 | + $count = count($terms) - 1; |
|
220 | 220 | |
221 | 221 | // If there are no terms, skip to the next taxonomy |
222 | - if ( empty( $terms ) ){ |
|
222 | + if (empty($terms)) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // Get a random index to use |
227 | - $index = rand( 0, $count ); |
|
227 | + $index = rand(0, $count); |
|
228 | 228 | |
229 | 229 | // Initialize our array |
230 | 230 | $post_data = array( |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | ); |
233 | 233 | |
234 | 234 | // Set the term data to update |
235 | - $post_data['tax_input'][ $tax ] = array( $terms[$index]->term_id ); |
|
235 | + $post_data['tax_input'][$tax] = array($terms[$index]->term_id); |
|
236 | 236 | |
237 | 237 | // Update the post with the taxonomy info |
238 | - $return = wp_update_post( $post_data ); |
|
238 | + $return = wp_update_post($post_data); |
|
239 | 239 | |
240 | 240 | // Return the error if it exists |
241 | - if ( is_wp_error( $return ) ){ |
|
242 | - error_log( $return->get_error_messages() ); |
|
241 | + if (is_wp_error($return)) { |
|
242 | + error_log($return->get_error_messages()); |
|
243 | 243 | return $return->get_error_messages(); |
244 | 244 | } |
245 | 245 |