@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param string $class Class name. |
| 23 | 23 | */ |
| 24 | -function dummypress_autoloader( $class ) { |
|
| 25 | - $namespace = explode( '\\', $class ); |
|
| 24 | +function dummypress_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 | $nss = array( |
| 34 | 34 | 'Abstracts', |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | 'Views' |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - if ( in_array( $namespace[1], $nss ) ){ |
|
| 40 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
| 41 | - $class = str_replace( '\\', '', $class ); |
|
| 42 | - $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
| 39 | + if (in_array($namespace[1], $nss)) { |
|
| 40 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '/\1', $class)); |
|
| 41 | + $class = str_replace('\\', '', $class); |
|
| 42 | + $file = dirname(__FILE__) . '/' . $class . '.php'; |
|
| 43 | 43 | } else { |
| 44 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
| 45 | - $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
| 44 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class)); |
|
| 45 | + $file = dirname(__FILE__) . '/includes/class-' . $class . '.php'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( is_readable( $file ) ) { |
|
| 49 | - require_once( $file ); |
|
| 48 | + if (is_readable($file)) { |
|
| 49 | + require_once($file); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | - spl_autoload_register( __NAMESPACE__ . '\dummypress_autoloader' ); |
|
| 52 | + spl_autoload_register(__NAMESPACE__ . '\dummypress_autoloader'); |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | function plugin() { |
| 62 | 62 | static $instance; |
| 63 | 63 | |
| 64 | - if ( null === $instance ) { |
|
| 64 | + if (null === $instance) { |
|
| 65 | 65 | $instance = new Plugin(); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -71,24 +71,24 @@ discard block |
||
| 71 | 71 | // Set our definitions for later use |
| 72 | 72 | plugin()->set_definitions( |
| 73 | 73 | (object) array( |
| 74 | - 'basename' => plugin_basename( __FILE__ ), |
|
| 75 | - 'directory' => plugin_dir_path( __FILE__ ), |
|
| 74 | + 'basename' => plugin_basename(__FILE__), |
|
| 75 | + 'directory' => plugin_dir_path(__FILE__), |
|
| 76 | 76 | 'file' => __FILE__, |
| 77 | 77 | 'slug' => 'test-content', |
| 78 | - 'url' => plugin_dir_url( __FILE__ ) |
|
| 78 | + 'url' => plugin_dir_url(__FILE__) |
|
| 79 | 79 | ) |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | // Register hook providers and views. |
| 83 | - plugin()->register_hooks( new AdminPage() ) |
|
| 84 | - ->register_hooks( new Ajax() ) |
|
| 85 | - ->register_view( new Views\Posts() ) |
|
| 86 | - ->register_view( new Views\Terms() ) |
|
| 87 | - ->register_view( new Views\Users() ) |
|
| 88 | - ->register_view( new Views\Various() ) |
|
| 89 | - ->register_type( new Types\Post() ) |
|
| 90 | - ->register_type( new Types\Term() ) |
|
| 91 | - ->register_type( new Types\User() ); |
|
| 83 | + plugin()->register_hooks(new AdminPage()) |
|
| 84 | + ->register_hooks(new Ajax()) |
|
| 85 | + ->register_view(new Views\Posts()) |
|
| 86 | + ->register_view(new Views\Terms()) |
|
| 87 | + ->register_view(new Views\Users()) |
|
| 88 | + ->register_view(new Views\Various()) |
|
| 89 | + ->register_type(new Types\Post()) |
|
| 90 | + ->register_type(new Types\Term()) |
|
| 91 | + ->register_type(new Types\User()); |
|
| 92 | 92 | |
| 93 | 93 | // Load textdomain hook |
| 94 | -add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) ); |
|
| 94 | +add_action('plugins_loaded', array(plugin(), 'load_textdomain')); |
|
@@ -3,16 +3,16 @@ |
||
| 3 | 3 | use DummyPress as test; |
| 4 | 4 | |
| 5 | 5 | // If uninstall is not called from WordPress, exit |
| 6 | -if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 6 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
| 7 | 7 | exit(); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | // Check if the current user has priveledges to run this method |
| 11 | -if ( ! current_user_can( 'activate_plugins' ) ){ |
|
| 11 | +if (!current_user_can('activate_plugins')) { |
|
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -require dirname( __FILE__ ) . '/includes/class-delete.php'; |
|
| 15 | +require dirname(__FILE__) . '/includes/class-delete.php'; |
|
| 16 | 16 | $delete = new test\Delete; |
| 17 | 17 | |
| 18 | 18 | // Delete all the things |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @subpackage Test Content |
| 10 | 10 | * @author Old Town Media |
| 11 | 11 | */ |
| 12 | -abstract class Type{ |
|
| 12 | +abstract class Type { |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * type |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * Registers the type with the rest of the plugin |
| 35 | 35 | */ |
| 36 | - public function register_type(){ |
|
| 36 | + public function register_type() { |
|
| 37 | 37 | |
| 38 | - add_filter( 'tc-types', array( $this, 'set_type' ) ); |
|
| 38 | + add_filter('tc-types', array($this, 'set_type')); |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param array $types Original types array |
| 47 | 47 | * @return array Modified types array with our current type |
| 48 | 48 | */ |
| 49 | - public function set_type( $types ){ |
|
| 49 | + public function set_type($types) { |
|
| 50 | 50 | |
| 51 | 51 | $types[] = $this->type; |
| 52 | 52 | return $types; |
@@ -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,10 +58,10 @@ 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 | - $html .= "<a class='nav-tab' data-type='".sanitize_title( $this->title )."' href='javascript:void(0)'>"; |
|
| 64 | + $html .= "<a class='nav-tab' data-type='" . sanitize_title($this->title) . "' href='javascript:void(0)'>"; |
|
| 65 | 65 | $html .= $this->title; |
| 66 | 66 | $html .= "</a>"; |
| 67 | 67 | |
@@ -78,10 +78,10 @@ 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 | - $html .= "<section class='test-content-tab' data-type='".sanitize_title( $this->title )."'>"; |
|
| 84 | + $html .= "<section class='test-content-tab' data-type='" . sanitize_title($this->title) . "'>"; |
|
| 85 | 85 | $html .= $this->actions_section(); |
| 86 | 86 | $html .= $this->options_section(); |
| 87 | 87 | $html .= "</section>"; |
@@ -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,13 +115,13 @@ 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 .= "<hr>"; |
| 120 | 120 | |
| 121 | 121 | $html .= "<div class='test-data-cpt'>"; |
| 122 | 122 | $html .= "<h3>"; |
| 123 | - $html .= "<span class='label'>".__( 'Quantity', 'dummybot' )."</span>"; |
|
| 124 | - $html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' > "; |
|
| 123 | + $html .= "<span class='label'>" . __('Quantity', 'dummybot') . "</span>"; |
|
| 124 | + $html .= "<input type='number' value='0' class='quantity-adjustment' for='" . $this->type . "' > "; |
|
| 125 | 125 | $html .= "</h3>"; |
| 126 | 126 | $html .= "</div>"; |
| 127 | 127 | |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | * @param string $text Text to display in the button. |
| 140 | 140 | * @return string HTML. |
| 141 | 141 | */ |
| 142 | - protected function build_button( $action, $slug, $text ){ |
|
| 142 | + protected function build_button($action, $slug, $text) { |
|
| 143 | 143 | $html = $dashicon = ''; |
| 144 | 144 | |
| 145 | - if ( $action == 'create' ){ |
|
| 145 | + if ($action == 'create') { |
|
| 146 | 146 | $dashicon = 'dashicons-plus'; |
| 147 | - } elseif ( $action == 'delete' ){ |
|
| 147 | + } elseif ($action == 'delete') { |
|
| 148 | 148 | $dashicon = 'dashicons-trash'; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | * @subpackage Test Content |
| 11 | 11 | * @author Old Town Media |
| 12 | 12 | */ |
| 13 | -class Posts extends Abs\View{ |
|
| 13 | +class Posts extends Abs\View { |
|
| 14 | 14 | |
| 15 | - public function __construct(){ |
|
| 15 | + public function __construct() { |
|
| 16 | 16 | |
| 17 | - $this->title = __( 'Posts', 'dummybot' ); |
|
| 17 | + $this->title = __('Posts', 'dummybot'); |
|
| 18 | 18 | $this->type = 'post'; |
| 19 | - $this->priority = 1; |
|
| 19 | + $this->priority = 1; |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return string HTML content. |
| 29 | 29 | */ |
| 30 | - protected function actions_section(){ |
|
| 30 | + protected function actions_section() { |
|
| 31 | 31 | $html = ''; |
| 32 | 32 | |
| 33 | 33 | // Loop through every post type available on the site |
| 34 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
| 34 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
| 35 | 35 | |
| 36 | - foreach ( $post_types as $post_type ) : |
|
| 36 | + foreach ($post_types as $post_type) : |
|
| 37 | 37 | |
| 38 | 38 | $skipped_cpts = array( |
| 39 | 39 | 'attachment' |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | 42 | // Skip banned cpts |
| 43 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
| 43 | + if (in_array($post_type->name, $skipped_cpts)) { |
|
| 44 | 44 | continue; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | $html .= "<h3>"; |
| 50 | 50 | |
| 51 | 51 | $html .= "<span class='label'>" . $post_type->labels->name . "</span>"; |
| 52 | - $html .= $this->build_button( 'create', $post_type->name, __( 'Create Test Data', 'dummybot' ) ); |
|
| 53 | - $html .= $this->build_button( 'delete', $post_type->name, __( 'Delete Test Data', 'dummybot' ) ); |
|
| 52 | + $html .= $this->build_button('create', $post_type->name, __('Create Test Data', 'dummybot')); |
|
| 53 | + $html .= $this->build_button('delete', $post_type->name, __('Delete Test Data', 'dummybot')); |
|
| 54 | 54 | |
| 55 | 55 | $html .= "</h3>"; |
| 56 | 56 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | * @subpackage Test Content |
| 11 | 11 | * @author Old Town Media |
| 12 | 12 | */ |
| 13 | -class Terms extends Abs\View{ |
|
| 13 | +class Terms extends Abs\View { |
|
| 14 | 14 | |
| 15 | - public function __construct(){ |
|
| 15 | + public function __construct() { |
|
| 16 | 16 | |
| 17 | - $this->title = __( 'Terms', 'dummybot' ); |
|
| 17 | + $this->title = __('Terms', 'dummybot'); |
|
| 18 | 18 | $this->type = 'term'; |
| 19 | - $this->priority = 2; |
|
| 19 | + $this->priority = 2; |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -28,34 +28,34 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string HTML content. |
| 30 | 30 | */ |
| 31 | - protected function actions_section(){ |
|
| 31 | + protected function actions_section() { |
|
| 32 | 32 | $html = ''; |
| 33 | 33 | |
| 34 | 34 | $taxonomies = get_taxonomies(); |
| 35 | 35 | |
| 36 | - foreach ( $taxonomies as $tax ) : |
|
| 36 | + foreach ($taxonomies as $tax) : |
|
| 37 | 37 | |
| 38 | 38 | $skipped_taxonomies = array( |
| 39 | - 'post_format', // We shouldn't be making random post format classes |
|
| 40 | - 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
| 41 | - 'nav_menu', // Menus are handled seperately of taxonomies |
|
| 39 | + 'post_format', // We shouldn't be making random post format classes |
|
| 40 | + 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
| 41 | + 'nav_menu', // Menus are handled seperately of taxonomies |
|
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | 44 | // Skip banned taxonomies |
| 45 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
| 45 | + if (in_array($tax, $skipped_taxonomies)) { |
|
| 46 | 46 | continue; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $taxonomy = get_taxonomy( $tax ); |
|
| 49 | + $taxonomy = get_taxonomy($tax); |
|
| 50 | 50 | |
| 51 | 51 | $html .= "<div class='test-data-cpt'>"; |
| 52 | 52 | |
| 53 | 53 | $html .= "<h3>"; |
| 54 | 54 | |
| 55 | - $html .= "<span class='label'>".$taxonomy->labels->name."</span>"; |
|
| 55 | + $html .= "<span class='label'>" . $taxonomy->labels->name . "</span>"; |
|
| 56 | 56 | |
| 57 | - $html .= $this->build_button( 'create', $tax, __( 'Create', 'dummybot' )." ".$taxonomy->labels->name ); |
|
| 58 | - $html .= $this->build_button( 'delete', $tax, __( 'Delete', 'dummybot' )." ".$taxonomy->labels->name ); |
|
| 57 | + $html .= $this->build_button('create', $tax, __('Create', 'dummybot') . " " . $taxonomy->labels->name); |
|
| 58 | + $html .= $this->build_button('delete', $tax, __('Delete', 'dummybot') . " " . $taxonomy->labels->name); |
|
| 59 | 59 | |
| 60 | 60 | $html .= "</h3>"; |
| 61 | 61 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | * @subpackage Test Content |
| 12 | 12 | * @author Old Town Media |
| 13 | 13 | */ |
| 14 | -class Users extends Abs\View{ |
|
| 14 | +class Users extends Abs\View { |
|
| 15 | 15 | |
| 16 | - public function __construct(){ |
|
| 16 | + public function __construct() { |
|
| 17 | 17 | |
| 18 | - $this->title = __( 'Users', 'dummybot' ); |
|
| 18 | + $this->title = __('Users', 'dummybot'); |
|
| 19 | 19 | $this->type = 'user'; |
| 20 | - $this->priority = 4; |
|
| 20 | + $this->priority = 4; |
|
| 21 | 21 | |
| 22 | 22 | } |
| 23 | 23 | |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string HTML content. |
| 30 | 30 | */ |
| 31 | - protected function actions_section(){ |
|
| 31 | + protected function actions_section() { |
|
| 32 | 32 | $html = ''; |
| 33 | 33 | |
| 34 | 34 | $user_class = new Type\User; |
| 35 | 35 | $roles = $user_class->get_roles(); |
| 36 | 36 | |
| 37 | - foreach ( $roles as $role ) : |
|
| 37 | + foreach ($roles as $role) : |
|
| 38 | 38 | |
| 39 | 39 | $html .= "<div class='test-data-cpt'>"; |
| 40 | 40 | |
| 41 | 41 | $html .= "<h3>"; |
| 42 | 42 | |
| 43 | 43 | $html .= "<span class='label'>" . $role['name'] . "</span>"; |
| 44 | - $html .= $this->build_button( 'create', $role['slug'], __( 'Create Users', 'dummybot' ) ); |
|
| 45 | - $html .= $this->build_button( 'delete', $role['slug'], __( 'Delete Users', 'dummybot' ) ); |
|
| 44 | + $html .= $this->build_button('create', $role['slug'], __('Create Users', 'dummybot')); |
|
| 45 | + $html .= $this->build_button('delete', $role['slug'], __('Delete Users', 'dummybot')); |
|
| 46 | 46 | |
| 47 | 47 | $html .= "</h3>"; |
| 48 | 48 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | * @subpackage Test Content |
| 11 | 11 | * @author Old Town Media |
| 12 | 12 | */ |
| 13 | -class Various extends Abs\View{ |
|
| 13 | +class Various extends Abs\View { |
|
| 14 | 14 | |
| 15 | - public function __construct(){ |
|
| 15 | + public function __construct() { |
|
| 16 | 16 | |
| 17 | - $this->title = __( 'Various', 'dummybot' ); |
|
| 17 | + $this->title = __('Various', 'dummybot'); |
|
| 18 | 18 | $this->type = 'all'; |
| 19 | - $this->priority = 10; |
|
| 19 | + $this->priority = 10; |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -28,15 +28,15 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string HTML content. |
| 30 | 30 | */ |
| 31 | - protected function actions_section(){ |
|
| 31 | + protected function actions_section() { |
|
| 32 | 32 | $html = ''; |
| 33 | 33 | |
| 34 | 34 | $html .= "<div class='test-data-cpt'>"; |
| 35 | 35 | |
| 36 | 36 | $html .= "<h3>"; |
| 37 | 37 | |
| 38 | - $html .= "<span class='label'>" . __( 'Clean Site', 'dummybot' ) . "</span>"; |
|
| 39 | - $html .= $this->build_button( 'delete', 'all', __( 'Delete All Test Data', 'dummybot' ) ); |
|
| 38 | + $html .= "<span class='label'>" . __('Clean Site', 'dummybot') . "</span>"; |
|
| 39 | + $html .= $this->build_button('delete', 'all', __('Delete All Test Data', 'dummybot')); |
|
| 40 | 40 | |
| 41 | 41 | $html .= "</h3>"; |
| 42 | 42 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $html Existing HTML content. |
| 55 | 55 | * @return string HTML section content. |
| 56 | 56 | */ |
| 57 | - protected function options_section( $html = '' ){ |
|
| 57 | + protected function options_section($html = '') { |
|
| 58 | 58 | return $html; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @subpackage Evans |
| 15 | 15 | * @author Old Town Media |
| 16 | 16 | */ |
| 17 | -class TestContent{ |
|
| 17 | +class TestContent { |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Title function. |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param int $num_words Number of words to return. |
| 27 | 27 | * @return string Random title string. |
| 28 | 28 | */ |
| 29 | - public static function title( $num_words = '' ){ |
|
| 29 | + public static function title($num_words = '') { |
|
| 30 | 30 | |
| 31 | 31 | $title = ''; |
| 32 | 32 | |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | // If we didn't choose a count, make one |
| 70 | - if ( empty( $num_words ) ){ |
|
| 71 | - $num_words = rand( 2, 10 ); |
|
| 70 | + if (empty($num_words)) { |
|
| 71 | + $num_words = rand(2, 10); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Pull random words |
| 75 | - for( $i = 1; $i <= $num_words; $i++ ){ |
|
| 76 | - $title .= $random_words[ rand( 0, 31 ) ] . " "; |
|
| 75 | + for ($i = 1; $i <= $num_words; $i++) { |
|
| 76 | + $title .= $random_words[rand(0, 31)] . " "; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - return apply_filters( "tc_title_data", substr( $title, 0, -1 ) ); |
|
| 79 | + return apply_filters("tc_title_data", substr($title, 0, -1)); |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return string Paragraph(s) of text. |
| 91 | 91 | */ |
| 92 | - public static function paragraphs(){ |
|
| 92 | + public static function paragraphs() { |
|
| 93 | 93 | |
| 94 | 94 | $content = ''; |
| 95 | 95 | |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | ); |
| 352 | 352 | |
| 353 | 353 | $used_keys = array(); |
| 354 | - for( $i = 1; $i < 7; $i++ ){ |
|
| 354 | + for ($i = 1; $i < 7; $i++) { |
|
| 355 | 355 | |
| 356 | 356 | // Pull a new random key and make sure we're not repeating any elements |
| 357 | - $key = rand( 0, 12 ); |
|
| 358 | - while( in_array( $key, $used_keys ) ){ |
|
| 359 | - $key = rand( 0, 12 ); |
|
| 357 | + $key = rand(0, 12); |
|
| 358 | + while (in_array($key, $used_keys)) { |
|
| 359 | + $key = rand(0, 12); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | $content .= $random_content_types[$key]; |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $used_keys[] = $key; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - return apply_filters( "tc_paragraphs_data", $content ); |
|
| 367 | + return apply_filters("tc_paragraphs_data", $content); |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @return string Plain text paragraphs. |
| 378 | 378 | */ |
| 379 | - public static function plain_text(){ |
|
| 379 | + public static function plain_text() { |
|
| 380 | 380 | |
| 381 | 381 | $paragraphs = array( |
| 382 | 382 | 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt luctus eros, a tincidunt massa aliquet sit amet. Sed faucibus, eros non lacinia porttitor, risus odio efficitur sapien, id porta urna massa ac est. Cras efficitur lacinia magna eget tempus. Fusce ex felis, finibus consectetur mi at, finibus rhoncus augue. In ut tortor lacinia, rutrum mauris vel, maximus tortor. Praesent ac arcu nec eros pharetra tristique. Morbi congue leo sed ipsum fermentum vulputate. Ut nulla eros, porta varius pulvinar eget, bibendum quis dolor. Morbi sed diam eu dui semper ornare nec quis nisl.', |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | 'Fusce semper erat tortor, at pulvinar risus luctus suscipit. Phasellus quis enim nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper dapibus odio, nec pellentesque sem laoreet sit amet. Maecenas ut enim tellus. Fusce malesuada mattis sem, porta interdum ex fermentum quis. Ut eget quam mi. In molestie volutpat feugiat. Nulla vel viverra nunc. Integer lobortis nisl vitae placerat egestas. Curabitur tristique nulla at libero blandit, a eleifend augue tempus.', |
| 392 | 392 | ); |
| 393 | 393 | |
| 394 | - return apply_filters( "tc_plain_text_data", $paragraphs[ rand( 0, 9 ) ] ); |
|
| 394 | + return apply_filters("tc_plain_text_data", $paragraphs[rand(0, 9)]); |
|
| 395 | 395 | |
| 396 | 396 | } |
| 397 | 397 | |
@@ -407,49 +407,49 @@ discard block |
||
| 407 | 407 | * @param int $post_id Post ID. |
| 408 | 408 | * @return mixed Attachment ID or WP Error. |
| 409 | 409 | */ |
| 410 | - public static function image( $post_id ){ |
|
| 410 | + public static function image($post_id) { |
|
| 411 | 411 | $file_array = array(); |
| 412 | 412 | |
| 413 | 413 | // Get the image from the API |
| 414 | 414 | $url = self::get_image_link(); |
| 415 | 415 | |
| 416 | 416 | // If the returned string is empty or it's not a string, try again. |
| 417 | - if ( empty( $url ) || !is_string( $url ) ){ |
|
| 417 | + if (empty($url) || !is_string($url)) { |
|
| 418 | 418 | |
| 419 | 419 | // Try again |
| 420 | 420 | $url = self::get_image_link(); |
| 421 | 421 | |
| 422 | 422 | // If it fails again, just give up |
| 423 | - if ( empty( $url ) || !is_string( $url ) ){ |
|
| 423 | + if (empty($url) || !is_string($url)) { |
|
| 424 | 424 | return; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // Download the file |
| 430 | - $tmp = \download_url( $url ); |
|
| 430 | + $tmp = \download_url($url); |
|
| 431 | 431 | |
| 432 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
| 432 | + preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); |
|
| 433 | 433 | |
| 434 | - $file_array['name'] = basename( $matches[0] ); |
|
| 434 | + $file_array['name'] = basename($matches[0]); |
|
| 435 | 435 | $file_array['tmp_name'] = $tmp; |
| 436 | 436 | |
| 437 | 437 | // Check for download errors |
| 438 | - if ( is_wp_error( $tmp ) ) { |
|
| 439 | - unlink( $file_array[ 'tmp_name' ] ); |
|
| 440 | - error_log( $tmp->get_error_message() ); |
|
| 438 | + if (is_wp_error($tmp)) { |
|
| 439 | + unlink($file_array['tmp_name']); |
|
| 440 | + error_log($tmp->get_error_message()); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | // Pull the image into the media library |
| 444 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
| 444 | + $image_id = media_handle_sideload($file_array, $post_id); |
|
| 445 | 445 | |
| 446 | 446 | // Check for handle sideload errors. |
| 447 | - if ( is_wp_error( $image_id ) ) { |
|
| 448 | - unlink( $file_array['tmp_name'] ); |
|
| 449 | - error_log( $image_id->get_error_message() ); |
|
| 447 | + if (is_wp_error($image_id)) { |
|
| 448 | + unlink($file_array['tmp_name']); |
|
| 449 | + error_log($image_id->get_error_message()); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - return apply_filters( "tc_image_data", $image_id ); |
|
| 452 | + return apply_filters("tc_image_data", $image_id); |
|
| 453 | 453 | |
| 454 | 454 | } |
| 455 | 455 | |
@@ -461,31 +461,31 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * @return string Image URL. |
| 463 | 463 | */ |
| 464 | - private static function get_image_link(){ |
|
| 464 | + private static function get_image_link() { |
|
| 465 | 465 | |
| 466 | 466 | // cURL an image API for a completely random photo |
| 467 | - $curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" ); |
|
| 467 | + $curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true"); |
|
| 468 | 468 | |
| 469 | - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); |
|
| 469 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); |
|
| 470 | 470 | |
| 471 | - $curl_response = curl_exec( $curl ); |
|
| 471 | + $curl_response = curl_exec($curl); |
|
| 472 | 472 | |
| 473 | 473 | // If our cURL failed |
| 474 | - if ( $curl_response === false ) { |
|
| 475 | - $info = curl_getinfo( $curl ); |
|
| 476 | - curl_close( $curl ); |
|
| 477 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
| 474 | + if ($curl_response === false) { |
|
| 475 | + $info = curl_getinfo($curl); |
|
| 476 | + curl_close($curl); |
|
| 477 | + die('error occured during curl exec. Additional info: ' . var_export($info)); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - curl_close( $curl ); |
|
| 480 | + curl_close($curl); |
|
| 481 | 481 | |
| 482 | 482 | // Decode the data |
| 483 | - $response = json_decode( $curl_response, true ); |
|
| 483 | + $response = json_decode($curl_response, true); |
|
| 484 | 484 | |
| 485 | 485 | // Check to make sure that the return contains a valid image extensions |
| 486 | 486 | preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches); |
| 487 | 487 | |
| 488 | - if ( !empty( $matches ) ){ |
|
| 488 | + if (!empty($matches)) { |
|
| 489 | 489 | return $response['url']; |
| 490 | 490 | } |
| 491 | 491 | |
@@ -500,12 +500,12 @@ discard block |
||
| 500 | 500 | * @param string $format PHP Date format. |
| 501 | 501 | * @return mixed Date in the format requested. |
| 502 | 502 | */ |
| 503 | - public static function date( $format ){ |
|
| 503 | + public static function date($format) { |
|
| 504 | 504 | |
| 505 | - $num_days = rand( 1, 60 ); |
|
| 506 | - $date = date( $format, strtotime( " +$num_days days" ) ); |
|
| 505 | + $num_days = rand(1, 60); |
|
| 506 | + $date = date($format, strtotime(" +$num_days days")); |
|
| 507 | 507 | |
| 508 | - return apply_filters( "tc_date_data", $date ); |
|
| 508 | + return apply_filters("tc_date_data", $date); |
|
| 509 | 509 | |
| 510 | 510 | } |
| 511 | 511 | |
@@ -517,19 +517,19 @@ discard block |
||
| 517 | 517 | * |
| 518 | 518 | * @return string Time string |
| 519 | 519 | */ |
| 520 | - public static function time(){ |
|
| 520 | + public static function time() { |
|
| 521 | 521 | |
| 522 | 522 | $times = array( |
| 523 | 523 | '8:00 am', |
| 524 | 524 | '5:00PM', |
| 525 | 525 | '13:00', |
| 526 | 526 | '2015', |
| 527 | - date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ), |
|
| 528 | - date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ), |
|
| 529 | - date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) ) |
|
| 527 | + date('G:i', strtotime(" +" . rand(4, 24) . " hours")), |
|
| 528 | + date('g:i', strtotime(" +" . rand(4, 24) . " hours")), |
|
| 529 | + date('G:i A', strtotime(" +" . rand(4, 24) . " hours")) |
|
| 530 | 530 | ); |
| 531 | 531 | |
| 532 | - return apply_filters( "tc_time_data", $times[ rand( 0, 6 ) ] ); |
|
| 532 | + return apply_filters("tc_time_data", $times[rand(0, 6)]); |
|
| 533 | 533 | |
| 534 | 534 | } |
| 535 | 535 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * |
| 542 | 542 | * @return string Timezone |
| 543 | 543 | */ |
| 544 | - public static function timezone(){ |
|
| 544 | + public static function timezone() { |
|
| 545 | 545 | |
| 546 | 546 | $timezones = array( |
| 547 | 547 | 'America/Denver', |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | 'UTC', |
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | - return apply_filters( "tc_timezone_data", $timezones[ rand( 0, 12 ) ] ); |
|
| 562 | + return apply_filters("tc_timezone_data", $timezones[rand(0, 12)]); |
|
| 563 | 563 | |
| 564 | 564 | } |
| 565 | 565 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * |
| 573 | 573 | * @return string Phone #. |
| 574 | 574 | */ |
| 575 | - public static function phone(){ |
|
| 575 | + public static function phone() { |
|
| 576 | 576 | |
| 577 | 577 | $phone_numbers = array( |
| 578 | 578 | '7203893101', |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | '+43 780 0047112', |
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | - return apply_filters( "tc_phone_data", $phone_numbers[ rand( 0, 10 ) ] ); |
|
| 591 | + return apply_filters("tc_phone_data", $phone_numbers[rand(0, 10)]); |
|
| 592 | 592 | |
| 593 | 593 | } |
| 594 | 594 | |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @return string Email address. |
| 602 | 602 | */ |
| 603 | - public static function email( $superrandom = false ){ |
|
| 603 | + public static function email($superrandom = false) { |
|
| 604 | 604 | |
| 605 | 605 | // In certain situations we need to ensure that the email is never |
| 606 | 606 | // duplicated, like in creating new users. |
| 607 | - if ( $superrandom !== false ){ |
|
| 607 | + if ($superrandom !== false) { |
|
| 608 | 608 | $user = $domain = ''; |
| 609 | 609 | |
| 610 | 610 | $tlds = array( |
@@ -619,18 +619,18 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | $char = '0123456789abcdefghijklmnopqrstuvwxyz'; |
| 621 | 621 | |
| 622 | - $user_length = mt_rand( 5, 20 ); |
|
| 623 | - $domain_length = mt_rand( 7, 12 ); |
|
| 622 | + $user_length = mt_rand(5, 20); |
|
| 623 | + $domain_length = mt_rand(7, 12); |
|
| 624 | 624 | |
| 625 | - for ( $i = 1; $i <= $user_length; $i++ ){ |
|
| 626 | - $user .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
|
| 625 | + for ($i = 1; $i <= $user_length; $i++) { |
|
| 626 | + $user .= substr($char, mt_rand(0, strlen($char)), 1); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - for ( $i = 1; $i <= $domain_length; $i++ ){ |
|
| 630 | - $domain .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
|
| 629 | + for ($i = 1; $i <= $domain_length; $i++) { |
|
| 630 | + $domain .= substr($char, mt_rand(0, strlen($char)), 1); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - $tld = $tlds[ mt_rand( 0, ( sizeof( $tlds ) - 1 ) ) ]; |
|
| 633 | + $tld = $tlds[mt_rand(0, (sizeof($tlds) - 1))]; |
|
| 634 | 634 | |
| 635 | 635 | $email = $user . "@" . $domain . '.' . $tld; |
| 636 | 636 | |
@@ -647,12 +647,12 @@ discard block |
||
| 647 | 647 | '[email protected]' |
| 648 | 648 | ); |
| 649 | 649 | |
| 650 | - $email = $email_addresses[ rand( 0, 7 ) ]; |
|
| 650 | + $email = $email_addresses[rand(0, 7)]; |
|
| 651 | 651 | |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | |
| 655 | - return apply_filters( "tc_email_data", $email ); |
|
| 655 | + return apply_filters("tc_email_data", $email); |
|
| 656 | 656 | |
| 657 | 657 | } |
| 658 | 658 | |
@@ -666,12 +666,12 @@ discard block |
||
| 666 | 666 | * |
| 667 | 667 | * @return string URL. |
| 668 | 668 | */ |
| 669 | - public static function link(){ |
|
| 669 | + public static function link() { |
|
| 670 | 670 | |
| 671 | 671 | $links = array( |
| 672 | 672 | 'http://google.com', |
| 673 | 673 | 'https://www.twitter.com', |
| 674 | - site_url( '/?iam=anextravariable' ), |
|
| 674 | + site_url('/?iam=anextravariable'), |
|
| 675 | 675 | 'github.com', |
| 676 | 676 | 'http://filebase.com', |
| 677 | 677 | 'http://facebook.com', |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | 'https://jalopnik.com/', |
| 680 | 680 | ); |
| 681 | 681 | |
| 682 | - return apply_filters( "tc_link_data", $links[ rand( 0, 7 ) ] ); |
|
| 682 | + return apply_filters("tc_link_data", $links[rand(0, 7)]); |
|
| 683 | 683 | |
| 684 | 684 | } |
| 685 | 685 | |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | * |
| 691 | 691 | * @return string URL. |
| 692 | 692 | */ |
| 693 | - public static function oembed(){ |
|
| 693 | + public static function oembed() { |
|
| 694 | 694 | |
| 695 | 695 | $links = array( |
| 696 | 696 | 'https://www.youtube.com/watch?v=A85-YQsm6pY', |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | 'https://www.instagram.com/p/-eyLo0RMfX', |
| 702 | 702 | ); |
| 703 | 703 | |
| 704 | - return apply_filters( "tc_oembed_data", $links[ rand( 0, 5 ) ] ); |
|
| 704 | + return apply_filters("tc_oembed_data", $links[rand(0, 5)]); |
|
| 705 | 705 | |
| 706 | 706 | } |
| 707 | 707 | |
@@ -715,10 +715,10 @@ discard block |
||
| 715 | 715 | * @param string $type Video service to get link from |
| 716 | 716 | * @return string URL. |
| 717 | 717 | */ |
| 718 | - public static function video( $type ){ |
|
| 718 | + public static function video($type) { |
|
| 719 | 719 | |
| 720 | 720 | // Switch through our video types. Expecting to add more in the future |
| 721 | - switch( $type ){ |
|
| 721 | + switch ($type) { |
|
| 722 | 722 | |
| 723 | 723 | // YouTube videos |
| 724 | 724 | case 'youtube' : |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - return apply_filters( "tc_video_data", $links[ rand( 0, 8 ) ] ); |
|
| 762 | + return apply_filters("tc_video_data", $links[rand(0, 8)]); |
|
| 763 | 763 | |
| 764 | 764 | } |
| 765 | 765 | |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | * |
| 771 | 771 | * @return array Randomly strung together name. |
| 772 | 772 | */ |
| 773 | - public static function name(){ |
|
| 773 | + public static function name() { |
|
| 774 | 774 | |
| 775 | 775 | $first_names = array( |
| 776 | 776 | 'Jacqui', |
@@ -819,11 +819,11 @@ discard block |
||
| 819 | 819 | ); |
| 820 | 820 | |
| 821 | 821 | $name = array( |
| 822 | - 'first' => $first_names[ rand( 0, 19 ) ], |
|
| 823 | - 'last' => $last_names[ rand( 0, 19 ) ] |
|
| 822 | + 'first' => $first_names[rand(0, 19)], |
|
| 823 | + 'last' => $last_names[rand(0, 19)] |
|
| 824 | 824 | ); |
| 825 | 825 | |
| 826 | - return apply_filters( "tc_name_data", $name ); |
|
| 826 | + return apply_filters("tc_name_data", $name); |
|
| 827 | 827 | |
| 828 | 828 | } |
| 829 | 829 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | * |
| 833 | 833 | * @return string Organization name. |
| 834 | 834 | */ |
| 835 | - public static function organization(){ |
|
| 835 | + public static function organization() { |
|
| 836 | 836 | |
| 837 | 837 | $orgs = array( |
| 838 | 838 | 'Red Cross', |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | 'Raviga', |
| 848 | 848 | ); |
| 849 | 849 | |
| 850 | - return apply_filters( "tc_organization_data", $orgs[ rand( 0, 9 ) ] ); |
|
| 850 | + return apply_filters("tc_organization_data", $orgs[rand(0, 9)]); |
|
| 851 | 851 | |
| 852 | 852 | } |
| 853 | 853 | |