Completed
Push — master ( 885fbd...5a8fbc )
by Mike
02:40
created
includes/class-connection-test.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @subpackage Evans
18 18
  * @author     Old Town Media
19 19
  */
20
-class ConnectionTest{
20
+class ConnectionTest {
21 21
 
22 22
 	/**
23 23
 	 * Run all of our connection tests.
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return boolean Status of connection to Internet/Splashbase.
28 28
 	 */
29
-	public function test(){
29
+	public function test() {
30 30
 
31 31
 		/*
32 32
 		 * Make sure that we're looking at the correct admin page
33 33
 		 */
34
-		if ( ! $this->check_admin_page() ){
34
+		if (!$this->check_admin_page()) {
35 35
 			return;
36 36
 		}
37 37
 
38 38
 		/*
39 39
 		 * Test #1 - Check for Airplane Mode plugin status
40 40
 		 */
41
-		if ( ! $this->check_airplane_mode() ){
41
+		if (!$this->check_airplane_mode()) {
42 42
 			return false;
43 43
 		}
44 44
 
45 45
 		/*
46 46
 		 * Test #2 - Check Internet connection in general
47 47
 		 */
48
-		if ( ! $this->check_internet() ){
48
+		if (!$this->check_internet()) {
49 49
 			return false;
50 50
 		}
51 51
 
52 52
 		/*
53 53
 		 * Test #3 - Check External URL itself (Splashbase here)
54 54
 		 */
55
-		if ( ! $this->check_external_url( 'http://www.splashbase.co/api/v1/images/' ) ){
55
+		if (!$this->check_external_url('http://www.splashbase.co/api/v1/images/')) {
56 56
 			return false;
57 57
 		}
58 58
 
@@ -75,22 +75,22 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return boolean Whether or not we're in the right place.
77 77
 	 */
78
-	private function check_admin_page(){
78
+	private function check_admin_page() {
79 79
 		global $current_screen;
80 80
 
81 81
 		// Only run if we're in the admin page
82
-		if ( !is_admin() ){
82
+		if (!is_admin()) {
83 83
 			return false;
84 84
 		}
85 85
 
86 86
 		// Get the current admin screen & verify that we're on the right one
87 87
 		// before continuing.
88
-		if ( isset ( $current_screen ) && 'tools_page_create-test-data' != $current_screen->base ){
88
+		if (isset ($current_screen) && 'tools_page_create-test-data' != $current_screen->base) {
89 89
 			return false;
90 90
 		}
91 91
 
92
-		$last_uri_bit = explode( '=', $_SERVER['REQUEST_URI'] );
93
-		if ( 'create-test-data' != end( $last_uri_bit ) ){
92
+		$last_uri_bit = explode('=', $_SERVER['REQUEST_URI']);
93
+		if ('create-test-data' != end($last_uri_bit)) {
94 94
 			return false;
95 95
 		}
96 96
 
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return boolean Connected or not.
110 110
 	 */
111
-	private function check_airplane_mode(){
111
+	private function check_airplane_mode() {
112 112
 
113
-		if ( class_exists( 'Airplane_Mode_Core' ) ){
113
+		if (class_exists('Airplane_Mode_Core')) {
114 114
 			// Is airplane mode active?
115
-			$airplane_mode = get_site_option( 'airplane-mode' );
115
+			$airplane_mode = get_site_option('airplane-mode');
116 116
 
117
-			if ( $airplane_mode === 'on' ){
117
+			if ($airplane_mode === 'on') {
118 118
 				return false;
119 119
 			}
120 120
 		}
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return boolean Connected or not.
135 135
 	 */
136
-	private function check_internet(){
136
+	private function check_internet() {
137 137
 
138 138
 		// Attempt to open a socket connection to Google
139
-		$connected = @fsockopen( "www.google.com", 80 );
139
+		$connected = @fsockopen("www.google.com", 80);
140 140
 
141
-		if ( !$connected ){
141
+		if (!$connected) {
142 142
 			return false;
143 143
 		}
144 144
 
145 145
 		// Close out our 1st test
146
-		fclose( $connected );
146
+		fclose($connected);
147 147
 
148 148
 		return true;
149 149
 
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	 * @param string $url External URL to attempt to reach.
161 161
 	 * @return boolean Connected or not.
162 162
 	 */
163
-	private function check_external_url( $url ){
163
+	private function check_external_url($url) {
164 164
 
165
-		$test_url = esc_url( $url );
166
-		$response = wp_remote_get( $test_url );
165
+		$test_url = esc_url($url);
166
+		$response = wp_remote_get($test_url);
167 167
 
168
-		if ( !is_array( $response ) ){
168
+		if (!is_array($response)) {
169 169
 			return false;
170 170
 		}
171 171
 
Please login to merge, or discard this patch.
includes/class-ajax.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class Ajax{
11
+class Ajax {
12 12
 
13 13
 	/**
14 14
 	 * reporting
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * Instantiate any WP hooks that need to be fired.
41 41
 	 */
42
-	public function hooks(){
42
+	public function hooks() {
43 43
 
44 44
 		$this->reporting    = new Reporting;
45 45
 		$this->action       = 'handle_test_data';
46 46
 
47
-		add_action( "wp_ajax_{$this->action}" , array( $this, 'handle_ajax' ) );
48
-		add_filter( 'option_active_plugins', array( $this, 'ajax_exclude_plugins' ) );
47
+		add_action("wp_ajax_{$this->action}", array($this, 'handle_ajax'));
48
+		add_filter('option_active_plugins', array($this, 'ajax_exclude_plugins'));
49 49
 
50 50
 	}
51 51
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param $plugin Plugin instance.
57 57
 	 * @return Ajax instance
58 58
 	 */
59
-	public function set_plugin( $plugin ) {
59
+	public function set_plugin($plugin) {
60 60
 
61 61
 		$this->plugin = $plugin;
62 62
 		return $this;
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 	 * @param array $plugins All active plugins.
76 76
 	 * @return array Whitelisted plugins.
77 77
 	 */
78
-	public function ajax_exclude_plugins( $plugins ) {
78
+	public function ajax_exclude_plugins($plugins) {
79 79
 
80
-		if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || ! isset( $_POST['action'] ) || false === strpos( $_POST['action'], $this->action ) ){
80
+		if (!defined('DOING_AJAX') || !DOING_AJAX || !isset($_POST['action']) || false === strpos($_POST['action'], $this->action)) {
81 81
 			return $plugins;
82 82
 		}
83 83
 
84
-		foreach( $plugins as $key => $plugin ) {
84
+		foreach ($plugins as $key => $plugin) {
85 85
 
86
-			if ( false !== strpos( $plugin, $this->plugin->definitions->slug ) ){
86
+			if (false !== strpos($plugin, $this->plugin->definitions->slug)) {
87 87
 				continue;
88 88
 			}
89 89
 
90
-			unset( $plugins[$key] );
90
+			unset($plugins[$key]);
91 91
 		}
92 92
 		
93 93
 		return $plugins;
@@ -102,21 +102,21 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function handle_ajax() {
104 104
 
105
-		$action		= $_REQUEST['todo'];
106
-		$nonce		= $_REQUEST['nonce'];
105
+		$action = $_REQUEST['todo'];
106
+		$nonce = $_REQUEST['nonce'];
107 107
 
108 108
 		// Verify that we have a proper logged in user and it's the right person
109
-		if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){
109
+		if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) {
110 110
 			return;
111 111
 		}
112 112
 
113
-		if ( $action == 'delete' ){
113
+		if ($action == 'delete') {
114 114
 
115
-			$this->deletion_routing( $_REQUEST );
115
+			$this->deletion_routing($_REQUEST);
116 116
 
117
-		} elseif ( $action == 'create' ){
117
+		} elseif ($action == 'create') {
118 118
 
119
-			$this->creation_routing( $_REQUEST );
119
+			$this->creation_routing($_REQUEST);
120 120
 
121 121
 		}
122 122
 
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * Choose which type of creation needs to be accomplished and route through
130 130
 	 * the correct class.
131 131
 	 */
132
-	private function creation_routing( $data ){
132
+	private function creation_routing($data) {
133 133
 
134
-		$type = 'DummyPress\Types\\' . ucwords( $data['type'] );
134
+		$type = 'DummyPress\Types\\' . ucwords($data['type']);
135 135
 		$object = new $type();
136
-		$return = $object->create_objects( $data['slug'], $data['connection'], true, 1 );
136
+		$return = $object->create_objects($data['slug'], $data['connection'], true, 1);
137 137
 
138
-		$clean = $this->reporting->create_report( $return );
138
+		$clean = $this->reporting->create_report($return);
139 139
 
140 140
 		echo $clean;
141 141
 
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 	 * Choose which type of deletion needs to be accomplished and route through
147 147
 	 * the correct method of Delete.
148 148
 	 */
149
-	private function deletion_routing( $data ){
149
+	private function deletion_routing($data) {
150 150
 
151 151
 		$delete_content = new Delete;
152 152
 
153
-		if ( $data['type'] == 'all' ){
153
+		if ($data['type'] == 'all') {
154 154
 
155 155
 			$return = $delete_content->delete_all_test_data();
156 156
 
157 157
 		} else {
158 158
 
159
-			$return = $delete_content->delete_objects( $data );
159
+			$return = $delete_content->delete_objects($data);
160 160
 
161 161
 		}
162 162
 
163
-		$clean = $this->reporting->create_report( $return );
163
+		$clean = $this->reporting->create_report($return);
164 164
 
165 165
 		echo $clean;
166 166
 
Please login to merge, or discard this patch.
includes/class-reporting.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
  * @subpackage Evans
11 11
  * @author     Old Town Media
12 12
  */
13
-class Reporting{
13
+class Reporting {
14 14
 
15
-	public function create_report( $data ){
15
+	public function create_report($data) {
16 16
 
17
-		$cleaned = json_encode( $this->parse_data( $data ) );
17
+		$cleaned = json_encode($this->parse_data($data));
18 18
 		return $cleaned;
19 19
 
20 20
 	}
21 21
 
22
-	private function parse_data( $data ){
22
+	private function parse_data($data) {
23 23
 
24 24
 		return $data;
25 25
 
Please login to merge, or discard this patch.
includes/class-admin-page.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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,15 +45,15 @@  discard block
 block discarded – undo
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_filter( 'plugin_action_links_' . $this->definitions->basename , array( $this, 'add_settings_link' ) );
56
-		add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) );
54
+		add_action('admin_menu', array($this, 'add_menu_item'));
55
+		add_filter('plugin_action_links_' . $this->definitions->basename, array($this, 'add_settings_link'));
56
+		add_action('admin_notices', array($this, 'internet_connected_admin_notice'));
57 57
 
58 58
 	}
59 59
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param Plugin $plugin Main plugin instance.
65 65
 	 */
66
-	public function set_plugin( $plugin ) {
66
+	public function set_plugin($plugin) {
67 67
 
68 68
 		$this->plugin = $plugin;
69 69
 		return $this;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$page = add_submenu_page(
82 82
 			'tools.php',
83
-			__( 'Create Dummy Content', 'dummybot' ),
84
-			__( 'DummyBot', 'dummybot' ),
83
+			__('Create Dummy Content', 'dummybot'),
84
+			__('DummyBot', 'dummybot'),
85 85
 			'manage_options',
86 86
 			'create-test-data',
87
-			array( $this, 'admin_page' )
87
+			array($this, 'admin_page')
88 88
 		);
89 89
 
90
-		add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) );
90
+		add_action('admin_print_styles-' . $page, array($this, 'load_scripts'));
91 91
 
92 92
 	}
93 93
 
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 	 * @param  array $links Existing links
98 98
 	 * @return array 		Modified links
99 99
 	 */
100
-	public function add_settings_link( $links ) {
100
+	public function add_settings_link($links) {
101 101
 
102
-		$settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'dummybot' ) . '</a>';
103
-  		array_push( $links, $settings_link );
102
+		$settings_link = '<a href="tools.php?page=create-test-data">' . __('Build Test Content', 'dummybot') . '</a>';
103
+  		array_push($links, $settings_link);
104 104
   		return $links;
105 105
 
106 106
 	}
@@ -113,24 +113,24 @@  discard block
 block discarded – undo
113 113
 	 * Internet, and the test fails displays a notice informing the user that
114 114
 	 * images will not pull into test data.
115 115
 	 */
116
-	public function internet_connected_admin_notice(){
116
+	public function internet_connected_admin_notice() {
117 117
 
118 118
 		// Get the current admin screen & verify that we're on the right one
119 119
 		// before continuing.
120 120
 		$screen = get_current_screen();
121 121
 
122
-		if ( $screen->base != 'tools_page_create-test-data' ){
122
+		if ($screen->base != 'tools_page_create-test-data') {
123 123
 			return;
124 124
 		}
125 125
 
126 126
 		// Check the response
127
-		if ( $this->connected ) {
127
+		if ($this->connected) {
128 128
 			// We got a response so early return
129 129
 			return;
130 130
 		} else {
131 131
 			// We didn't get a reponse so print the notice out
132 132
 			echo '<div class="notice notice-error">';
133
-		        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.', 'dummybot' ).'</p>';
133
+		        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.', 'dummybot') . '</p>';
134 134
 		    echo '</div>';
135 135
 		}
136 136
 
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * Load our script in the admin section and serve in data.
142 142
 	 */
143
-	public function load_scripts(){
143
+	public function load_scripts() {
144 144
 
145
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
146
-		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) );
145
+		wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__)));
146
+		wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__)));
147 147
 
148 148
 		$data = array(
149
-			'nonce'			=> wp_create_nonce( 'handle-test-data' ),
149
+			'nonce'			=> wp_create_nonce('handle-test-data'),
150 150
 			'strings'	=> array(
151
-				'createdStr'	=> __( 'Created', 'dummybot' ),
152
-				'deletedStr'	=> __( 'Deleting', 'dummybot' ),
153
-				'creatingStr'	=> __( 'Creating', 'dummybot' ),
151
+				'createdStr'	=> __('Created', 'dummybot'),
152
+				'deletedStr'	=> __('Deleting', 'dummybot'),
153
+				'creatingStr'	=> __('Creating', 'dummybot'),
154 154
 			),
155 155
 		);
156 156
 
157
-		wp_localize_script( 'test-content-js', 'test_content', $data );
157
+		wp_localize_script('test-content-js', 'test_content', $data);
158 158
 
159 159
 	}
160 160
 
@@ -162,24 +162,24 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * Print out our admin page to control test data.
164 164
 	 */
165
-	public function admin_page(){
165
+	public function admin_page() {
166 166
 		echo '<div class="wrap" id="options_editor">' . "\n";
167 167
 
168
-			echo '<h2>' . __( 'Create Test Data' , 'dummybot' ) . '</h2>' . "\n";
168
+			echo '<h2>' . __('Create Test Data', 'dummybot') . '</h2>' . "\n";
169 169
 
170 170
 			echo "<div class='nav-tab-wrapper'>";
171 171
 
172
-				do_action( 'tc-admin-tabs', '' );
172
+				do_action('tc-admin-tabs', '');
173 173
 
174 174
 			echo "</div>";
175 175
 
176 176
 			echo "";
177 177
 
178
-				do_action( 'tc-admin-sections', '' );
178
+				do_action('tc-admin-sections', '');
179 179
 
180 180
 			echo "";
181 181
 
182
-			echo "<input type='hidden' id='connection-status' value='".$this->connected."'>";
182
+			echo "<input type='hidden' id='connection-status' value='" . $this->connected . "'>";
183 183
 
184 184
 			echo "<pre class='test-data-status-box' id='status-updates'></pre>";
185 185
 
Please login to merge, or discard this patch.
includes/class-delete.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,27 +9,27 @@  discard block
 block discarded – undo
9 9
  * @subpackage Evans
10 10
  * @author     Old Town Media
11 11
  */
12
-class Delete{
12
+class Delete {
13 13
 
14 14
 	/**
15 15
 	 * Delete all test content created ever.
16 16
 	 *
17 17
 	 * @access private
18 18
 	 */
19
-	public function delete_all_test_data(){
19
+	public function delete_all_test_data() {
20 20
 		$return = '';
21 21
 
22
-		if ( ! $this->user_can_delete() ){
22
+		if (!$this->user_can_delete()) {
23 23
 			return;
24 24
 		}
25 25
 
26
-		$types = apply_filters( 'tc-types', array() );
26
+		$types = apply_filters('tc-types', array());
27 27
 
28
-		if ( !empty( $types ) ){
28
+		if (!empty($types)) {
29 29
 
30
-			foreach ( $types as $type ){
30
+			foreach ($types as $type) {
31 31
 
32
-				$class = 'DummyPress\Types\\' . ucwords( $type );
32
+				$class = 'DummyPress\Types\\' . ucwords($type);
33 33
 				$object = new $class();
34 34
 
35 35
 				$return .= $object->delete_all();
@@ -53,23 +53,23 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param string $data Information about the type.
55 55
 	 */
56
-	public function delete_objects( $data ){
56
+	public function delete_objects($data) {
57 57
 
58 58
 		// Make sure that the current user is logged in & has full permissions.
59
-		if ( !$this->user_can_delete() ){
59
+		if (!$this->user_can_delete()) {
60 60
 			return;
61 61
 		}
62 62
 
63
-		if ( empty( $data ) ){
63
+		if (empty($data)) {
64 64
 			return;
65 65
 		}
66 66
 
67
-		$type = 'DummyPress\Types\\' . ucwords( $data['type'] );
67
+		$type = 'DummyPress\Types\\' . ucwords($data['type']);
68 68
 		$slug = $data['slug'];
69 69
 
70 70
 		$object = new $type();
71 71
 
72
-		return $object->delete( $slug );
72
+		return $object->delete($slug);
73 73
 
74 74
 	}
75 75
 
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @see is_user_logged_in, current_user_can
81 81
 	 */
82
-	public function user_can_delete(){
82
+	public function user_can_delete() {
83 83
 
84 84
 		// User must be logged in
85
-		if ( !is_user_logged_in() ){
85
+		if (!is_user_logged_in()) {
86 86
 			return false;
87 87
 		}
88 88
 
89 89
 		// User must have editor priveledges, at a minimum
90
-		if ( !current_user_can( 'delete_others_posts' ) ){
90
+		if (!current_user_can('delete_others_posts')) {
91 91
 			return false;
92 92
 		}
93 93
 
Please login to merge, or discard this patch.
includes/class-metabox-types.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class MetaboxTypes{
11
+class MetaboxTypes {
12 12
 
13 13
 	/**
14 14
 	 * Decide which cmb library to try and loop to get our metaboxes.
@@ -22,26 +22,26 @@  discard block
 block discarded – undo
22 22
 	 * @param string $slug Post Type slug ID.
23 23
 	 * @return array Fields to fill in for our post object.
24 24
 	 */
25
-	public function get_metaboxes( $slug ){
25
+	public function get_metaboxes($slug) {
26 26
 		$cmb2_fields = $cmb_fields = $acf_fields = array();
27 27
 
28 28
 		// CMB2
29
-		if ( class_exists( 'CMB2', false ) ) {
30
-			$cmb2_fields = $this->get_cmb2_metaboxes( $slug );
29
+		if (class_exists('CMB2', false)) {
30
+			$cmb2_fields = $this->get_cmb2_metaboxes($slug);
31 31
 		}
32 32
 
33 33
 		// Custom Metaboxes and Fields (CMB1)
34
-		if ( class_exists( 'cmb_Meta_Box', false ) ) {
35
-			$cmb_fields = $this->get_cmb1_metaboxes( $slug );
34
+		if (class_exists('cmb_Meta_Box', false)) {
35
+			$cmb_fields = $this->get_cmb1_metaboxes($slug);
36 36
 		}
37 37
 
38 38
 		// Advanced Custom Fields (ACF Free)
39
-		if ( class_exists( 'acf', false ) ) {
40
-			$acf_fields = $this->get_acf_free_metaboxes( $slug );
39
+		if (class_exists('acf', false)) {
40
+			$acf_fields = $this->get_acf_free_metaboxes($slug);
41 41
 		}
42 42
 
43 43
 		// Return our array
44
-		return array_merge( $cmb2_fields, $cmb_fields, $acf_fields );
44
+		return array_merge($cmb2_fields, $cmb_fields, $acf_fields);
45 45
 
46 46
 	}
47 47
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param string $slug Post type.
57 57
 	 * @return array Fields array.
58 58
 	 */
59
-	private function get_acf_free_metaboxes( $slug ){
59
+	private function get_acf_free_metaboxes($slug) {
60 60
 
61 61
 		$fields = array();
62 62
 
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 		$fieldsets = $this->get_all_acf_field_groups();
65 65
 
66 66
 		// Return empty array if there are no fieldsets at all
67
-		if ( empty( $fieldsets ) ){
67
+		if (empty($fieldsets)) {
68 68
 			return $fields;
69 69
 		}
70 70
 
71 71
 		// Loop through each fieldset for possible matches
72
-		foreach ( $fieldsets as $fieldset ){
72
+		foreach ($fieldsets as $fieldset) {
73 73
 
74
-			if ( $this->is_acf_field_in_post_type( $slug, $fieldset ) ){
74
+			if ($this->is_acf_field_in_post_type($slug, $fieldset)) {
75 75
 
76 76
 				// If this is the first group of fields, simply set the value
77 77
 				// Else, merge this group with the previous one
78
-				if ( empty( $fields ) ){
78
+				if (empty($fields)) {
79 79
 					$fields = $fieldset->fields;
80 80
 				} else {
81
-					$fields = array_merge( $fields, $fieldset->fields );
81
+					$fields = array_merge($fields, $fieldset->fields);
82 82
 				}
83 83
 
84 84
 			}
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 	 * @param object $fieldset Fieldset group.
100 100
 	 * @return boolean Whether or not the grouping is assigned to the post type.
101 101
 	 */
102
-	private function is_acf_field_in_post_type( $slug, $fieldset ){
102
+	private function is_acf_field_in_post_type($slug, $fieldset) {
103 103
 
104 104
 		// Make sure we have something to parse
105
-		if ( empty( $fieldset ) ){
105
+		if (empty($fieldset)) {
106 106
 			return false;
107 107
 		}
108 108
 
109 109
 		// Loop through the rules to check for post type matches
110
-		foreach ( $fieldset->rules as $rule ){
111
-			if ( $rule['param'] === 'post_type' && $rule['value'] === $slug ){
110
+		foreach ($fieldset->rules as $rule) {
111
+			if ($rule['param'] === 'post_type' && $rule['value'] === $slug) {
112 112
 				return true;
113 113
 			}
114 114
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return array All acf fieldsets.
132 132
 	 */
133
-	private function get_all_acf_field_groups(){
133
+	private function get_all_acf_field_groups() {
134 134
 		$info = $rules = $fields = array();
135 135
 
136 136
 		$args = array(
@@ -138,31 +138,31 @@  discard block
 block discarded – undo
138 138
 			'posts_per_page'=> 500
139 139
 		);
140 140
 
141
-		$objects = new \WP_Query( $args );
141
+		$objects = new \WP_Query($args);
142 142
 
143
-		if ( $objects->have_posts() ) :
144
-			while ( $objects->have_posts() ) : $objects->the_post();
143
+		if ($objects->have_posts()) :
144
+			while ($objects->have_posts()) : $objects->the_post();
145 145
 
146
-				$data = get_metadata( 'post', get_the_id() );
146
+				$data = get_metadata('post', get_the_id());
147 147
 
148
-				foreach ( $data['rule'] as $rule ){
149
-					$rules[] = unserialize( $rule );
148
+				foreach ($data['rule'] as $rule) {
149
+					$rules[] = unserialize($rule);
150 150
 				}
151 151
 
152
-				foreach ( $data as $key => $value ){
153
-					if ( substr( $key, 0, 6 ) == 'field_' ) :
154
-						$field_detail = unserialize( $value[0] );
152
+				foreach ($data as $key => $value) {
153
+					if (substr($key, 0, 6) == 'field_') :
154
+						$field_detail = unserialize($value[0]);
155 155
 						$fields[] = array(
156 156
 							'key'	 => $field_detail['key'],
157 157
 							'type'	 => $field_detail['type'],
158 158
 							'name'	 => $field_detail['label'],
159 159
 							'id'	 => $field_detail['name'],
160 160
 							'extras' => (object) array(
161
-								'chars'	 => ( isset( $field_detail['maxlength'] ) ? $field_detail['maxlength'] : '' ),
162
-								'max'	 => ( isset( $field_detail['max'] ) ? $field_detail['max'] : '' ),
163
-								'min'	 => ( isset( $field_detail['min'] ) ? $field_detail['min'] : '' ),
161
+								'chars'	 => (isset($field_detail['maxlength']) ? $field_detail['maxlength'] : ''),
162
+								'max'	 => (isset($field_detail['max']) ? $field_detail['max'] : ''),
163
+								'min'	 => (isset($field_detail['min']) ? $field_detail['min'] : ''),
164 164
 							),
165
-							'options' => ( isset( $field_detail['choices'] ) ? $field_detail['choices'] : '' ),
165
+							'options' => (isset($field_detail['choices']) ? $field_detail['choices'] : ''),
166 166
 							'source' =>'acf',
167 167
 						);
168 168
 
@@ -196,60 +196,60 @@  discard block
 block discarded – undo
196 196
 	 * @param string $slug a custom post type ID.
197 197
 	 * @return array Array of fields.
198 198
 	 */
199
-	private function get_cmb2_metaboxes( $slug ){
199
+	private function get_cmb2_metaboxes($slug) {
200 200
 
201 201
 		$fields = array();
202 202
 
203 203
 		// Get all metaboxes from CMB2 library
204
-		$all_metaboxes = apply_filters( 'cmb2_meta_boxes', array() );
204
+		$all_metaboxes = apply_filters('cmb2_meta_boxes', array());
205 205
 
206 206
 		// Loop through all possible sets of metaboxes added the old way
207
-		foreach ( $all_metaboxes as $metabox_array ){
207
+		foreach ($all_metaboxes as $metabox_array) {
208 208
 
209 209
 			// If the custom post type ID matches this set of fields, set & stop
210
-			if ( in_array( $slug, $metabox_array['object_types'] ) ) {
210
+			if (in_array($slug, $metabox_array['object_types'])) {
211 211
 
212 212
 				// If this is the first group of fields, simply set the value
213 213
 				// Else, merge this group with the previous one
214
-				if ( empty( $fields ) ){
214
+				if (empty($fields)) {
215 215
 					$fields = $metabox_array['fields'];
216 216
 				} else {
217
-					$fields = array_merge( $fields, $metabox_array['fields'] );
217
+					$fields = array_merge($fields, $metabox_array['fields']);
218 218
 				}
219 219
 			}
220 220
 
221 221
 		}
222 222
 
223 223
 		// Loop through all metaboxes added the new way
224
-		foreach ( \CMB2_Boxes::get_all() as $cmb ) {
224
+		foreach (\CMB2_Boxes::get_all() as $cmb) {
225 225
 
226 226
 			// Create the default
227 227
 			$match = false;
228 228
 
229 229
 			// Establish correct cmb types
230
-			if ( is_string( $cmb->meta_box['object_types'] ) ){
231
-				if ( $cmb->meta_box['object_types'] == $slug ){
230
+			if (is_string($cmb->meta_box['object_types'])) {
231
+				if ($cmb->meta_box['object_types'] == $slug) {
232 232
 					$match = true;
233 233
 				}
234 234
 			} else {
235
-				if ( in_array( $slug, $cmb->meta_box['object_types'] ) ){
235
+				if (in_array($slug, $cmb->meta_box['object_types'])) {
236 236
 					$match = true;
237 237
 				}
238 238
 			}
239 239
 
240
-			if ( $match !== true ){
240
+			if ($match !== true) {
241 241
 				continue;
242 242
 			}
243 243
 
244
-			if ( empty( $fields ) ){
244
+			if (empty($fields)) {
245 245
 				$fields = $cmb->meta_box['fields'];
246 246
 			} else {
247
-				$fields = array_merge( $fields, $cmb->meta_box['fields'] );
247
+				$fields = array_merge($fields, $cmb->meta_box['fields']);
248 248
 			}
249 249
 
250 250
 		}
251 251
 
252
-		$fields = $this->add_source( $fields, 'cmb2' );
252
+		$fields = $this->add_source($fields, 'cmb2');
253 253
 
254 254
 		return $fields;
255 255
 
@@ -270,50 +270,50 @@  discard block
 block discarded – undo
270 270
 	 * @param string $slug a custom post type ID.
271 271
 	 * @return array Array of fields.
272 272
 	 */
273
-	private function get_cmb1_metaboxes( $slug ){
273
+	private function get_cmb1_metaboxes($slug) {
274 274
 
275 275
 		$fields = array();
276 276
 
277 277
 		// Get all metaboxes from CMB2 library
278
-		$all_metaboxes = apply_filters( 'cmb_meta_boxes', array() );
278
+		$all_metaboxes = apply_filters('cmb_meta_boxes', array());
279 279
 
280 280
 		// Loop through all possible sets of metaboxes
281
-		foreach ( $all_metaboxes as $metabox_array ){
281
+		foreach ($all_metaboxes as $metabox_array) {
282 282
 
283 283
 			// If the custom post type ID matches this set of fields, set & stop
284
-			if ( in_array( $slug, $metabox_array['pages'] ) ) {
284
+			if (in_array($slug, $metabox_array['pages'])) {
285 285
 
286 286
 				// If this is the first group of fields, simply set the value
287 287
 				// Else, merge this group with the previous one
288
-				if ( empty( $fields ) ){
288
+				if (empty($fields)) {
289 289
 					$fields = $metabox_array['fields'];
290 290
 				} else {
291
-					$fields = array_merge( $fields, $metabox_array['fields'] );
291
+					$fields = array_merge($fields, $metabox_array['fields']);
292 292
 				}
293 293
 			}
294 294
 
295 295
 		}
296 296
 
297 297
 		// Identify Human Made's CMB library
298
-		if ( defined( 'CMB_DEV' ) ){
299
-			$fields = $this->add_source( $fields, 'cmb_hm' );
298
+		if (defined('CMB_DEV')) {
299
+			$fields = $this->add_source($fields, 'cmb_hm');
300 300
 		// Default to CMB1 library
301 301
 		} else {
302
-			$fields = $this->add_source( $fields, 'cmb1' );
302
+			$fields = $this->add_source($fields, 'cmb1');
303 303
 		}
304 304
 
305 305
 		return $fields;
306 306
 
307 307
 	}
308 308
 
309
-	private function add_source( $fields, $source ){
309
+	private function add_source($fields, $source) {
310 310
 
311
-		if ( empty( $fields ) || empty( $source ) ){
311
+		if (empty($fields) || empty($source)) {
312 312
 			return $fields;
313 313
 		}
314 314
 
315
-		foreach ( $fields as $key => $value ){
316
-			$fields[ $key ]['source'] = $source;
315
+		foreach ($fields as $key => $value) {
316
+			$fields[$key]['source'] = $source;
317 317
 		}
318 318
 
319 319
 		return $fields;
Please login to merge, or discard this patch.
includes/class-plugin.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
66 66
 	 * @param  object $provider Hook provider.
67 67
 	 * @return object $this
68 68
 	 */
69
-	public function register_view( $provider ) {
69
+	public function register_view($provider) {
70 70
 
71 71
 		$provider->register_view();
72 72
 		return $this;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param  object $provider Hook provider.
81 81
 	 * @return object $this
82 82
 	 */
83
-	public function register_type( $provider ) {
83
+	public function register_type($provider) {
84 84
 
85 85
 		$provider->register_type();
86 86
 		return $this;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @see load_plugin_textdomain
95 95
 	 */
96 96
 	public function load_textdomain() {
97
-	    load_plugin_textdomain( 'dummybot', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' );
97
+	    load_plugin_textdomain('dummybot', FALSE, basename(dirname($this->definitions->file)) . '/languages/');
98 98
 	}
99 99
 
100 100
 }
Please login to merge, or discard this patch.
types/term.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @subpackage Evans
13 13
  * @author     Old Town Media
14 14
  */
15
-class Term extends Abs\Type{
15
+class Term extends Abs\Type {
16 16
 
17 17
 	/**
18 18
 	 * type
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 	 * @param string $slug a custom post type ID.
38 38
 	 * @param int $num Optional. Number of posts to create.
39 39
 	 */
40
-	public function create_objects( $slug, $connection, $num = '' ){
40
+	public function create_objects($slug, $connection, $num = '') {
41 41
 
42 42
 		// If we're missing a custom post type id - don't do anything
43
-		if ( empty( $slug ) ){
43
+		if (empty($slug)) {
44 44
 			return;
45 45
 		}
46 46
 
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 		$this->connected = $connection;
49 49
 
50 50
 		// If we forgot to put in a quantity, make one for us
51
-		if ( empty( $num ) ){
52
-			$num = rand( 5, 30 );
51
+		if (empty($num)) {
52
+			$num = rand(5, 30);
53 53
 		}
54 54
 
55 55
 		// Create test terms
56
-		for( $i = 0; $i < $num; $i++ ){
56
+		for ($i = 0; $i < $num; $i++) {
57 57
 
58
-			$return = $this->create_test_object( $slug );
58
+			$return = $this->create_test_object($slug);
59 59
 
60 60
 			return $return;
61 61
 
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @param string $slug a custom post type ID.
79 79
 	 */
80
-	private function create_test_object( $slug ){
80
+	private function create_test_object($slug) {
81 81
 
82 82
 		// Get a random title
83
-		$title = apply_filters( "tc_{$slug}_term_title", TestContent::title() );
83
+		$title = apply_filters("tc_{$slug}_term_title", TestContent::title());
84 84
 
85 85
 		$return = wp_insert_term(
86 86
 			$title,
87 87
 			$slug,
88
-			apply_filters( "tc_{$slug}_term_arguments", array(
88
+			apply_filters("tc_{$slug}_term_arguments", array(
89 89
 					'description'=> TestContent::title(),
90
-					'slug' => sanitize_title( $title ),
90
+					'slug' => sanitize_title($title),
91 91
 				)
92 92
 			)
93 93
 		);
94 94
 
95 95
 		// Then, set a test content flag on the new post for later deletion
96
-		add_term_meta( $return['term_id'], 'dummypress_test_data', '__test__', true );
96
+		add_term_meta($return['term_id'], 'dummypress_test_data', '__test__', true);
97 97
 
98 98
 		// Check if we have errors and return them or created message
99
-		if ( is_wp_error( $return ) ){
100
-			error_log( $return->get_error_message() );
99
+		if (is_wp_error($return)) {
100
+			error_log($return->get_error_message());
101 101
 			return $return;
102 102
 		} else {
103 103
 			return array(
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 				'object'	=> 'term',
106 106
 				'oid'		=> $return['term_id'],
107 107
 				'type'		=> $slug,
108
-				'link_edit'	=> admin_url( '/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id'] ),
109
-				'link_view'	=> get_term_link( $return['term_id'] )
108
+				'link_edit'	=> admin_url('/edit-tags.php?action=edit&taxonomy=' . $slug . '&tag_ID=' . $return['term_id']),
109
+				'link_view'	=> get_term_link($return['term_id'])
110 110
 			);
111 111
 		}
112 112
 
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @see Delete
121 121
 	 */
122
-	public function delete_all(){
122
+	public function delete_all() {
123 123
 
124
-		$delete =  new Delete;
124
+		$delete = new Delete;
125 125
 
126 126
 		// Make sure that the current user is logged in & has full permissions.
127
-		if ( ! $delete->user_can_delete() ){
127
+		if (!$delete->user_can_delete()) {
128 128
 			return;
129 129
 		}
130 130
 
131 131
 		// Loop through all taxonomies and remove any data
132 132
 		$taxonomies = get_taxonomies();
133
-		foreach ( $taxonomies as $tax ) :
133
+		foreach ($taxonomies as $tax) :
134 134
 
135
-			$this->delete( $tax );
135
+			$this->delete($tax);
136 136
 
137 137
 		endforeach;
138 138
 
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param string $slug a custom post type ID.
152 152
 	 */
153
-	public function delete( $slug ){
153
+	public function delete($slug) {
154 154
 
155
-		$delete =  new Delete;
155
+		$delete = new Delete;
156 156
 
157 157
 		// Make sure that the current user is logged in & has full permissions.
158
-		if ( !$delete->user_can_delete() ){
158
+		if (!$delete->user_can_delete()) {
159 159
 			return;
160 160
 		}
161 161
 
162 162
 		// Check that $cptslg has a string.
163
-		if ( empty( $slug ) ){
163
+		if (empty($slug)) {
164 164
 			return;
165 165
 		}
166 166
 
@@ -182,16 +182,16 @@  discard block
 block discarded – undo
182 182
 		    )
183 183
 		);
184 184
 
185
-		$terms = get_terms( $slug, $args );
185
+		$terms = get_terms($slug, $args);
186 186
 
187
-		if ( !empty( $terms ) ){
187
+		if (!empty($terms)) {
188 188
 
189 189
 			$events = array();
190 190
 
191
-			foreach ( $terms as $term ){
191
+			foreach ($terms as $term) {
192 192
 
193 193
 				// Double check our set user meta value
194
-				if ( '__test__' != get_term_meta( $term->term_id, 'dummypress_test_data', true ) && '__test__' != get_term_meta( $term->term_id, 'evans_test_content', true ) ){
194
+				if ('__test__' != get_term_meta($term->term_id, 'dummypress_test_data', true) && '__test__' != get_term_meta($term->term_id, 'evans_test_content', true)) {
195 195
 					continue;
196 196
 				}
197 197
 
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
 				);
204 204
 
205 205
 				// Delete our term
206
-				wp_delete_term( $term->term_id, $slug );
206
+				wp_delete_term($term->term_id, $slug);
207 207
 
208 208
 			}
209 209
 
210
-			$taxonomy = get_taxonomy( $slug );
210
+			$taxonomy = get_taxonomy($slug);
211 211
 
212 212
 			$events[] = array(
213 213
 				'action'	=> 'general',
214
-				'message'	=> __( 'Deleted', 'dummybot' ) . ' ' . $taxonomy->labels->name
214
+				'message'	=> __('Deleted', 'dummybot') . ' ' . $taxonomy->labels->name
215 215
 			);
216 216
 
217 217
 			return $events;
Please login to merge, or discard this patch.
types/user.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @subpackage Evans
14 14
  * @author     Old Town Media
15 15
  */
16
-class User extends Abs\Type{
16
+class User extends Abs\Type {
17 17
 
18 18
 	/**
19 19
 	 * type
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 	 * @param boolean $connection Whether or not we're connected to the Internet.
40 40
 	 * @param int $num Optional. Number of posts to create.
41 41
 	 */
42
-	public function create_objects( $slug, $connection, $num = '' ){
42
+	public function create_objects($slug, $connection, $num = '') {
43 43
 
44 44
 		// If we're missing a custom post type id - don't do anything
45
-		if ( empty( $slug ) ){
45
+		if (empty($slug)) {
46 46
 			return;
47 47
 		}
48 48
 
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 		$this->connected = $connection;
51 51
 
52 52
 		// If we forgot to put in a quantity, make one for us
53
-		if ( empty( $num ) ){
54
-			$num = rand( 5, 30 );
53
+		if (empty($num)) {
54
+			$num = rand(5, 30);
55 55
 		}
56 56
 
57 57
 		// Create test posts
58
-		for( $i = 0; $i < $num; $i++ ){
58
+		for ($i = 0; $i < $num; $i++) {
59 59
 
60
-			$return = $this->create_test_object( $slug );
60
+			$return = $this->create_test_object($slug);
61 61
 
62 62
 			return $return;
63 63
 
@@ -79,36 +79,36 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param string $slug a custom post type ID.
81 81
 	 */
82
-	private function create_test_object( $slug ){
82
+	private function create_test_object($slug) {
83 83
 
84
-		if ( !is_user_logged_in() ){
84
+		if (!is_user_logged_in()) {
85 85
 			return false;
86 86
 		}
87 87
 
88
-		$name = apply_filters( "tc_{$slug}_user_name", TestContent::name() );
88
+		$name = apply_filters("tc_{$slug}_user_name", TestContent::name());
89 89
 
90 90
 		// First, insert our post
91 91
 		$userdata = array(
92
-			'user_pass'			=> wp_generate_password( 12, true, true ),
93
-			'user_login'		=> strtolower( $name['first'] . $name['last'] ) . rand( 10, 100 ),
94
-			'user_email'		=> apply_filters( "tc_{$slug}_user_email", TestContent::email( true ) ),
95
-			'display_name'		=> strtolower( $name['first'] . $name['last'] ),
92
+			'user_pass'			=> wp_generate_password(12, true, true),
93
+			'user_login'		=> strtolower($name['first'] . $name['last']) . rand(10, 100),
94
+			'user_email'		=> apply_filters("tc_{$slug}_user_email", TestContent::email(true)),
95
+			'display_name'		=> strtolower($name['first'] . $name['last']),
96 96
 			'first_name'		=> $name['first'],
97 97
 			'last_name'			=> $name['last'],
98 98
 			'description'		=> TestContent::title(),
99
-			'user_registered'	=> date( 'Y-m-d H:i:s' ),
99
+			'user_registered'	=> date('Y-m-d H:i:s'),
100 100
 			'role'				=> $slug,
101 101
 		);
102 102
 
103 103
 		// Insert the user
104
-		$user_id = wp_insert_user( apply_filters( "tc_{$slug}_user_arguments", $userdata ) );
104
+		$user_id = wp_insert_user(apply_filters("tc_{$slug}_user_arguments", $userdata));
105 105
 
106 106
 		// Then, set a test content flag on the new post for later deletion
107
-		add_user_meta( $user_id, 'dummypress_test_data', '__test__', true );
107
+		add_user_meta($user_id, 'dummypress_test_data', '__test__', true);
108 108
 
109 109
 		// Check if we have errors and return them or created message
110
-		if ( is_wp_error( $user_id ) ){
111
-			error_log( $user_id->get_error_message() );
110
+		if (is_wp_error($user_id)) {
111
+			error_log($user_id->get_error_message());
112 112
 			return $user_id;
113 113
 		} else {
114 114
 			return array(
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 				'object'	=> 'user',
117 117
 				'oid'		=> $user_id,
118 118
 				'type'		=> $slug,
119
-				'link_edit'	=> admin_url( '/user-edit.php?user_id=' . $user_id ),
120
-				'link_view' => get_author_posts_url( $user_id )
119
+				'link_edit'	=> admin_url('/user-edit.php?user_id=' . $user_id),
120
+				'link_view' => get_author_posts_url($user_id)
121 121
 			);
122 122
 		}
123 123
 
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return array Array of roles for use in creation and deletion
135 135
 	 */
136
-	public function get_roles(){
136
+	public function get_roles() {
137 137
 		global $wp_roles;
138 138
 		$clean_roles = array();
139 139
 
140 140
 	    $role_names = $wp_roles->get_names();
141
-		$flipped = array_flip( $role_names );
141
+		$flipped = array_flip($role_names);
142 142
 
143 143
 		// Loop through all available roles
144 144
 		$roles = get_editable_roles();
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 			'Administrator'
148 148
 		);
149 149
 
150
-		foreach ( $roles as $role ){
150
+		foreach ($roles as $role) {
151 151
 
152
-			if ( in_array( $role['name'], $skipped_roles ) ){
152
+			if (in_array($role['name'], $skipped_roles)) {
153 153
 				continue;
154 154
 			}
155 155
 
156 156
 			$clean_roles[] = array(
157 157
 				'name'	=> $role['name'],
158
-				'slug'	=> $flipped[ $role['name'] ]
158
+				'slug'	=> $flipped[$role['name']]
159 159
 			);
160 160
 
161 161
 		}
@@ -170,27 +170,27 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @see Delete
172 172
 	 */
173
-	public function delete_all(){
173
+	public function delete_all() {
174 174
 
175
-		$delete =  new Delete;
175
+		$delete = new Delete;
176 176
 
177 177
 		// Make sure that the current user is logged in & has full permissions.
178
-		if ( ! $delete->user_can_delete() ){
178
+		if (!$delete->user_can_delete()) {
179 179
 			return;
180 180
 		}
181 181
 
182 182
 		// Loop through all post types and remove any test data
183
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
184
-		foreach ( $post_types as $post_type ) :
183
+		$post_types = get_post_types(array('public' => true), 'objects');
184
+		foreach ($post_types as $post_type) :
185 185
 
186
-		    $this->delete( $post_type->name );
186
+		    $this->delete($post_type->name);
187 187
 
188 188
 		endforeach;
189 189
 
190 190
 		// Loop through all user roles and remove any data
191
-		foreach ( $this->get_roles() as $role ) :
191
+		foreach ($this->get_roles() as $role) :
192 192
 
193
-			$this->delete( $role['slug'] );
193
+			$this->delete($role['slug']);
194 194
 
195 195
 		endforeach;
196 196
 
@@ -208,17 +208,17 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @param string $slug a custom post type ID.
210 210
 	 */
211
-	public function delete( $slug ){
211
+	public function delete($slug) {
212 212
 
213 213
 		$delete = new Delete;
214 214
 
215 215
 		// Make sure that the current user is logged in & has full permissions.
216
-		if ( !$delete->user_can_delete() ){
216
+		if (!$delete->user_can_delete()) {
217 217
 			return;
218 218
 		}
219 219
 
220 220
 		// Check that $cptslg has a string.
221
-		if ( empty( $slug ) ){
221
+		if (empty($slug)) {
222 222
 			return;
223 223
 		}
224 224
 
@@ -241,22 +241,22 @@  discard block
 block discarded – undo
241 241
 			),
242 242
 		);
243 243
 
244
-		$objects = new \WP_User_Query( $query );
245
-		$users	 = $objects->get_results();
244
+		$objects = new \WP_User_Query($query);
245
+		$users = $objects->get_results();
246 246
 
247
-		if ( !empty( $users ) ){
247
+		if (!empty($users)) {
248 248
 
249 249
 			$events = array();
250 250
 
251
-			foreach ( $users as $user ){
251
+			foreach ($users as $user) {
252 252
 
253 253
 				// Make sure we can't delete ourselves by accident
254
-				if ( $user->ID == get_current_user_id() ){
254
+				if ($user->ID == get_current_user_id()) {
255 255
 					continue;
256 256
 				}
257 257
 
258 258
 				// Double check our set user meta value
259
-				if ( '__test__' != get_user_meta( $user->ID, 'dummypress_test_data', true ) && '__test__' != get_user_meta( $user->ID, 'evans_test_content', true ) ){
259
+				if ('__test__' != get_user_meta($user->ID, 'dummypress_test_data', true) && '__test__' != get_user_meta($user->ID, 'evans_test_content', true)) {
260 260
 					continue;
261 261
 				}
262 262
 
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
 				);
269 269
 
270 270
 				// Force delete the user
271
-				wp_delete_user( $user->ID );
271
+				wp_delete_user($user->ID);
272 272
 
273 273
 			}
274 274
 
275 275
 			$events[] = array(
276 276
 				'action'	=> 'general',
277
-				'message'	=> __( 'Deleted', 'dummybot' ) . ' ' . $slug
277
+				'message'	=> __('Deleted', 'dummybot') . ' ' . $slug
278 278
 			);
279 279
 
280 280
 			return $events;
Please login to merge, or discard this patch.