@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @type array $defaults |
| 25 | 25 | */ |
| 26 | - protected $defaults = array( 'points' => 100 ); |
|
| 26 | + protected $defaults = array('points' => 100); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Construct the class. |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | public function __construct() { |
| 37 | 37 | |
| 38 | 38 | $this->init( |
| 39 | - _x( 'Registration', 'points hook name', 'wordpoints' ) |
|
| 40 | - , array( 'description' => _x( 'Registering with the site.', 'points hook description', 'wordpoints' ) ) |
|
| 39 | + _x('Registration', 'points hook name', 'wordpoints') |
|
| 40 | + , array('description' => _x('Registering with the site.', 'points hook description', 'wordpoints')) |
|
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | - add_action( 'user_register', array( $this, 'hook' ) ); |
|
| 44 | - add_filter( 'wordpoints_points_log-register', array( $this, 'logs' ) ); |
|
| 43 | + add_action('user_register', array($this, 'hook')); |
|
| 44 | + add_filter('wordpoints_points_log-register', array($this, 'logs')); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return void |
| 57 | 57 | */ |
| 58 | - public function hook( $user_id ) { |
|
| 58 | + public function hook($user_id) { |
|
| 59 | 59 | |
| 60 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
| 60 | + foreach ($this->get_instances() as $number => $instance) { |
|
| 61 | 61 | |
| 62 | - if ( isset( $instance['points'] ) ) { |
|
| 63 | - wordpoints_add_points( $user_id, $instance['points'], $this->points_type( $number ), 'register' ); |
|
| 62 | + if (isset($instance['points'])) { |
|
| 63 | + wordpoints_add_points($user_id, $instance['points'], $this->points_type($number), 'register'); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function logs() { |
| 78 | 78 | |
| 79 | - return _x( 'Registration.', 'points log description', 'wordpoints' ); |
|
| 79 | + return _x('Registration.', 'points log description', 'wordpoints'); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | } // class WordPoints_Registration_Points_Hook |
@@ -33,21 +33,21 @@ discard block |
||
| 33 | 33 | public function __construct() { |
| 34 | 34 | |
| 35 | 35 | parent::__construct( |
| 36 | - _x( 'Comment Received', 'points hook name', 'wordpoints' ) |
|
| 36 | + _x('Comment Received', 'points hook name', 'wordpoints') |
|
| 37 | 37 | , array( |
| 38 | - 'description' => __( 'Receiving a comment.', 'wordpoints' ), |
|
| 38 | + 'description' => __('Receiving a comment.', 'wordpoints'), |
|
| 39 | 39 | /* translators: the post type name. */ |
| 40 | - 'post_type_description' => __( 'Receiving a comment on a %s.', 'wordpoints' ), |
|
| 40 | + 'post_type_description' => __('Receiving a comment on a %s.', 'wordpoints'), |
|
| 41 | 41 | /* translators: %s will be the post's title. */ |
| 42 | - 'log_text_post_title' => _x( 'Received a comment on %s.', 'points log description', 'wordpoints' ), |
|
| 43 | - 'log_text_no_post_title' => _x( 'Received a comment.', 'points log description', 'wordpoints' ), |
|
| 42 | + 'log_text_post_title' => _x('Received a comment on %s.', 'points log description', 'wordpoints'), |
|
| 43 | + 'log_text_no_post_title' => _x('Received a comment.', 'points log description', 'wordpoints'), |
|
| 44 | 44 | /* translators: %s will be the post's title. */ |
| 45 | - 'log_text_post_title_reverse' => _x( 'Comment received on %s removed.', 'points log description', 'wordpoints' ), |
|
| 46 | - 'log_text_no_post_title_reverse' => _x( 'Comment received removed.', 'points log description', 'wordpoints' ), |
|
| 45 | + 'log_text_post_title_reverse' => _x('Comment received on %s removed.', 'points log description', 'wordpoints'), |
|
| 46 | + 'log_text_no_post_title_reverse' => _x('Comment received removed.', 'points log description', 'wordpoints'), |
|
| 47 | 47 | /* translators: %s is the name of a post type. */ |
| 48 | - 'log_text_post_type' => _x( 'Received a comment on a %s.', 'points log description', 'wordpoints' ), |
|
| 48 | + 'log_text_post_type' => _x('Received a comment on a %s.', 'points log description', 'wordpoints'), |
|
| 49 | 49 | /* translators: %s is the name of a post type. */ |
| 50 | - 'log_text_post_type_reverse' => _x( 'Comment received on a %s removed.', 'points log description', 'wordpoints' ), |
|
| 50 | + 'log_text_post_type_reverse' => _x('Comment received on a %s removed.', 'points log description', 'wordpoints'), |
|
| 51 | 51 | ) |
| 52 | 52 | ); |
| 53 | 53 | } |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @since 1.8.0 |
| 57 | 57 | */ |
| 58 | - protected function shortcircuit_hook( $new_status, $old_status, $comment ) { |
|
| 58 | + protected function shortcircuit_hook($new_status, $old_status, $comment) { |
|
| 59 | 59 | |
| 60 | - if ( parent::shortcircuit_hook( $new_status, $old_status, $comment ) ) { |
|
| 60 | + if (parent::shortcircuit_hook($new_status, $old_status, $comment)) { |
|
| 61 | 61 | return true; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $post = get_post( $comment->comment_post_ID ); |
|
| 64 | + $post = get_post($comment->comment_post_ID); |
|
| 65 | 65 | |
| 66 | - if ( $post && (int) $post->post_author === (int) $comment->user_id ) { |
|
| 66 | + if ($post && (int) $post->post_author === (int) $comment->user_id) { |
|
| 67 | 67 | return true; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @since 1.8.0 |
| 75 | 75 | */ |
| 76 | - protected function select_user_to_award( $comment, $post ) { |
|
| 76 | + protected function select_user_to_award($comment, $post) { |
|
| 77 | 77 | return $post->post_author; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -7,61 +7,61 @@ |
||
| 7 | 7 | * @since 2.1.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -add_action( 'wordpoints_init_app-components', 'wordpoints_points_components_app_init' ); |
|
| 10 | +add_action('wordpoints_init_app-components', 'wordpoints_points_components_app_init'); |
|
| 11 | 11 | |
| 12 | -add_action( 'wordpoints_init_app-components-points', 'wordpoints_points_apps_init' ); |
|
| 13 | -add_action( 'wordpoints_init_app-components-points-logs', 'wordpoints_points_logs_apps_init' ); |
|
| 12 | +add_action('wordpoints_init_app-components-points', 'wordpoints_points_apps_init'); |
|
| 13 | +add_action('wordpoints_init_app-components-points-logs', 'wordpoints_points_logs_apps_init'); |
|
| 14 | 14 | |
| 15 | -add_action( 'wordpoints_init_app_registry-components-points-logs-views', 'wordpoints_points_logs_views_init' ); |
|
| 16 | -add_action( 'wordpoints_init_app_registry-components-points-logs-viewing_restrictions', 'wordpoints_points_logs_viewing_restrictions_init' ); |
|
| 15 | +add_action('wordpoints_init_app_registry-components-points-logs-views', 'wordpoints_points_logs_views_init'); |
|
| 16 | +add_action('wordpoints_init_app_registry-components-points-logs-viewing_restrictions', 'wordpoints_points_logs_viewing_restrictions_init'); |
|
| 17 | 17 | |
| 18 | -add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_points_hook_reactors_init' ); |
|
| 19 | -add_action( 'wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_points_hook_reaction_stores_init' ); |
|
| 20 | -add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_points_hook_extensions_init' ); |
|
| 18 | +add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_points_hook_reactors_init'); |
|
| 19 | +add_action('wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_points_hook_reaction_stores_init'); |
|
| 20 | +add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_points_hook_extensions_init'); |
|
| 21 | 21 | |
| 22 | -if ( get_option( 'wordpoints_points_register_legacy_post_publish_event' ) ) { |
|
| 23 | - add_action( 'wordpoints_register_post_type_hook_events', 'wordpoints_points_register_legacy_post_publish_events' ); |
|
| 22 | +if (get_option('wordpoints_points_register_legacy_post_publish_event')) { |
|
| 23 | + add_action('wordpoints_register_post_type_hook_events', 'wordpoints_points_register_legacy_post_publish_events'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -add_action( 'wp_enqueue_scripts', 'wordpoints_points_register_scripts', 5 ); |
|
| 27 | -add_action( 'admin_enqueue_scripts', 'wordpoints_points_register_scripts', 5 ); |
|
| 26 | +add_action('wp_enqueue_scripts', 'wordpoints_points_register_scripts', 5); |
|
| 27 | +add_action('admin_enqueue_scripts', 'wordpoints_points_register_scripts', 5); |
|
| 28 | 28 | |
| 29 | -add_filter( 'wordpoints_format_points', 'wordpoints_format_points_filter', 5, 3 ); |
|
| 29 | +add_filter('wordpoints_format_points', 'wordpoints_format_points_filter', 5, 3); |
|
| 30 | 30 | |
| 31 | -add_action( 'deleted_user', 'wordpoints_delete_points_logs_for_user' ); |
|
| 32 | -add_action( 'delete_blog', 'wordpoints_delete_points_logs_for_blog' ); |
|
| 31 | +add_action('deleted_user', 'wordpoints_delete_points_logs_for_user'); |
|
| 32 | +add_action('delete_blog', 'wordpoints_delete_points_logs_for_blog'); |
|
| 33 | 33 | |
| 34 | -add_action( 'wordpoints_points_type_form_top', 'wordpoints_points_settings_custom_meta_key_message' ); |
|
| 35 | -add_action( 'wordpoints_admin_points_logs_tab', 'wordpoints_points_logs_custom_meta_key_message' ); |
|
| 34 | +add_action('wordpoints_points_type_form_top', 'wordpoints_points_settings_custom_meta_key_message'); |
|
| 35 | +add_action('wordpoints_admin_points_logs_tab', 'wordpoints_points_logs_custom_meta_key_message'); |
|
| 36 | 36 | |
| 37 | -add_action( 'init', 'wordpoints_points_add_global_cache_groups', 5 ); |
|
| 37 | +add_action('init', 'wordpoints_points_add_global_cache_groups', 5); |
|
| 38 | 38 | |
| 39 | -add_action( 'wordpoints_register_points_logs_queries', 'wordpoints_register_default_points_logs_queries' ); |
|
| 39 | +add_action('wordpoints_register_points_logs_queries', 'wordpoints_register_default_points_logs_queries'); |
|
| 40 | 40 | |
| 41 | -add_action( 'wordpoints_points_log-profile_edit', 'wordpoints_points_logs_profile_edit', 10, 6 ); |
|
| 42 | -add_action( 'wordpoints_points_log-comment_disapprove', 'wordpoints_points_logs_comment_disapprove', 10, 6 ); |
|
| 43 | -add_action( 'wordpoints_points_log-post_delete', 'wordpoints_points_logs_post_delete', 10, 6 ); |
|
| 41 | +add_action('wordpoints_points_log-profile_edit', 'wordpoints_points_logs_profile_edit', 10, 6); |
|
| 42 | +add_action('wordpoints_points_log-comment_disapprove', 'wordpoints_points_logs_comment_disapprove', 10, 6); |
|
| 43 | +add_action('wordpoints_points_log-post_delete', 'wordpoints_points_logs_post_delete', 10, 6); |
|
| 44 | 44 | |
| 45 | -add_action( 'wordpoints_points_altered', 'wordpoints_clean_points_logs_cache', 10, 3 ); |
|
| 46 | -add_action( 'wordpoints_points_altered', 'wordpoints_clean_points_top_users_cache', 10, 3 ); |
|
| 45 | +add_action('wordpoints_points_altered', 'wordpoints_clean_points_logs_cache', 10, 3); |
|
| 46 | +add_action('wordpoints_points_altered', 'wordpoints_clean_points_top_users_cache', 10, 3); |
|
| 47 | 47 | |
| 48 | -add_action( 'user_register', 'wordpoints_clean_points_top_users_cache_user_register' ); |
|
| 48 | +add_action('user_register', 'wordpoints_clean_points_top_users_cache_user_register'); |
|
| 49 | 49 | |
| 50 | -add_action( 'wordpoints_modules_loaded', 'WordPoints_Points_Hooks::initialize_hooks' ); |
|
| 50 | +add_action('wordpoints_modules_loaded', 'WordPoints_Points_Hooks::initialize_hooks'); |
|
| 51 | 51 | |
| 52 | -add_action( 'widgets_init', 'wordpoints_register_points_widgets' ); |
|
| 52 | +add_action('widgets_init', 'wordpoints_register_points_widgets'); |
|
| 53 | 53 | |
| 54 | -add_action( 'wordpoints_points_hooks_register', 'wordpoints_register_points_hooks' ); |
|
| 54 | +add_action('wordpoints_points_hooks_register', 'wordpoints_register_points_hooks'); |
|
| 55 | 55 | |
| 56 | -if ( ! is_multisite() || is_wordpoints_network_active() ) { |
|
| 57 | - add_action( 'deleted_user', 'wordpoints_clean_points_top_users_cache_user_deleted' ); |
|
| 56 | +if ( ! is_multisite() || is_wordpoints_network_active()) { |
|
| 57 | + add_action('deleted_user', 'wordpoints_clean_points_top_users_cache_user_deleted'); |
|
| 58 | 58 | } else { |
| 59 | - add_action( 'remove_user_from_blog', 'wordpoints_clean_points_top_users_cache_user_deleted' ); |
|
| 59 | + add_action('remove_user_from_blog', 'wordpoints_clean_points_top_users_cache_user_deleted'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -WordPoints_Shortcodes::register( 'wordpoints_points_top', 'WordPoints_Points_Top_Shortcode' ); |
|
| 63 | -WordPoints_Shortcodes::register( 'wordpoints_points_logs', 'WordPoints_Points_Logs_Shortcode' ); |
|
| 64 | -WordPoints_Shortcodes::register( 'wordpoints_points', 'WordPoints_User_Points_Shortcode' ); |
|
| 65 | -WordPoints_Shortcodes::register( 'wordpoints_how_to_get_points', 'WordPoints_How_To_Get_Points_Shortcode' ); |
|
| 62 | +WordPoints_Shortcodes::register('wordpoints_points_top', 'WordPoints_Points_Top_Shortcode'); |
|
| 63 | +WordPoints_Shortcodes::register('wordpoints_points_logs', 'WordPoints_Points_Logs_Shortcode'); |
|
| 64 | +WordPoints_Shortcodes::register('wordpoints_points', 'WordPoints_User_Points_Shortcode'); |
|
| 65 | +WordPoints_Shortcodes::register('wordpoints_how_to_get_points', 'WordPoints_How_To_Get_Points_Shortcode'); |
|
| 66 | 66 | |
| 67 | 67 | // EOF |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @deprecated 2.1.0 |
| 99 | 99 | */ |
| 100 | 100 | public static function init() { |
| 101 | - _deprecated_function( __METHOD__, '2.1.0' ); |
|
| 101 | + _deprecated_function(__METHOD__, '2.1.0'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $class_name A 'WordPoints_Points_Hook' class name. |
| 110 | 110 | */ |
| 111 | - public static function register( $class_name ) { |
|
| 111 | + public static function register($class_name) { |
|
| 112 | 112 | |
| 113 | 113 | self::$classes[] = $class_name; |
| 114 | 114 | } |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @since 1.4.0 |
| 129 | 129 | */ |
| 130 | - do_action( 'wordpoints_points_hooks_register' ); |
|
| 130 | + do_action('wordpoints_points_hooks_register'); |
|
| 131 | 131 | |
| 132 | - $classes = array_unique( self::$classes ); |
|
| 132 | + $classes = array_unique(self::$classes); |
|
| 133 | 133 | |
| 134 | - foreach ( $classes as $class_name ) { |
|
| 134 | + foreach ($classes as $class_name) { |
|
| 135 | 135 | |
| 136 | 136 | $hook_type = new $class_name(); |
| 137 | - self::$hook_types[ $hook_type->get_id_base() ] = $hook_type; |
|
| 137 | + self::$hook_types[$hook_type->get_id_base()] = $hook_type; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @since 1.0.0 |
| 144 | 144 | */ |
| 145 | - do_action( 'wordpoints_points_hooks_registered' ); |
|
| 145 | + do_action('wordpoints_points_hooks_registered'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -166,25 +166,25 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return WordPoints_Points_Hook|false The hook object, or false for invalid ID. |
| 168 | 168 | */ |
| 169 | - public static function get_handler( $hook_id ) { |
|
| 169 | + public static function get_handler($hook_id) { |
|
| 170 | 170 | |
| 171 | - list( $hook_type, $id_number ) = explode( '-', $hook_id ); |
|
| 171 | + list($hook_type, $id_number) = explode('-', $hook_id); |
|
| 172 | 172 | |
| 173 | - $hook_type = self::get_handler_by_id_base( $hook_type ); |
|
| 173 | + $hook_type = self::get_handler_by_id_base($hook_type); |
|
| 174 | 174 | |
| 175 | - if ( false === $hook_type ) { |
|
| 175 | + if (false === $hook_type) { |
|
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $type = ( self::$network_mode ) ? 'network' : 'standard'; |
|
| 179 | + $type = (self::$network_mode) ? 'network' : 'standard'; |
|
| 180 | 180 | |
| 181 | - $instances = $hook_type->get_instances( $type ); |
|
| 181 | + $instances = $hook_type->get_instances($type); |
|
| 182 | 182 | |
| 183 | - if ( ! isset( $instances[ $id_number ] ) ) { |
|
| 183 | + if ( ! isset($instances[$id_number])) { |
|
| 184 | 184 | return false; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $hook_type->set_number( $id_number ); |
|
| 187 | + $hook_type->set_number($id_number); |
|
| 188 | 188 | |
| 189 | 189 | return $hook_type; |
| 190 | 190 | } |
@@ -201,13 +201,13 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @return WordPoints_Points_Hook|false False if no handler found. |
| 203 | 203 | */ |
| 204 | - public static function get_handler_by_id_base( $id_base ) { |
|
| 204 | + public static function get_handler_by_id_base($id_base) { |
|
| 205 | 205 | |
| 206 | - if ( ! isset( self::$hook_types[ $id_base ] ) ) { |
|
| 206 | + if ( ! isset(self::$hook_types[$id_base])) { |
|
| 207 | 207 | return false; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - return self::$hook_types[ $id_base ]; |
|
| 210 | + return self::$hook_types[$id_base]; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -221,35 +221,35 @@ discard block |
||
| 221 | 221 | * installed. Only needed if on multisite. If |
| 222 | 222 | * omitted, the current site ID is used. |
| 223 | 223 | */ |
| 224 | - public static function uninstall_hook_types( $hook_types, array $site_ids = null ) { |
|
| 224 | + public static function uninstall_hook_types($hook_types, array $site_ids = null) { |
|
| 225 | 225 | |
| 226 | - _deprecated_function( __METHOD__, '2.0.0', 'WordPoints_Un_Installer_Base::$uninstall' ); |
|
| 226 | + _deprecated_function(__METHOD__, '2.0.0', 'WordPoints_Un_Installer_Base::$uninstall'); |
|
| 227 | 227 | |
| 228 | 228 | $hook_types = (array) $hook_types; |
| 229 | 229 | |
| 230 | - if ( is_multisite() ) { |
|
| 230 | + if (is_multisite()) { |
|
| 231 | 231 | |
| 232 | - foreach ( $hook_types as $hook_type ) { |
|
| 233 | - delete_site_option( "wordpoints_hook-{$hook_type}" ); |
|
| 232 | + foreach ($hook_types as $hook_type) { |
|
| 233 | + delete_site_option("wordpoints_hook-{$hook_type}"); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( ! isset( $site_ids ) ) { |
|
| 237 | - $site_ids = array( get_current_blog_id() ); |
|
| 236 | + if ( ! isset($site_ids)) { |
|
| 237 | + $site_ids = array(get_current_blog_id()); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - foreach ( $site_ids as $site_id ) { |
|
| 240 | + foreach ($site_ids as $site_id) { |
|
| 241 | 241 | |
| 242 | - switch_to_blog( $site_id ); |
|
| 243 | - foreach ( $hook_types as $hook_type ) { |
|
| 244 | - delete_option( "wordpoints_hook-{$hook_type}" ); |
|
| 242 | + switch_to_blog($site_id); |
|
| 243 | + foreach ($hook_types as $hook_type) { |
|
| 244 | + delete_option("wordpoints_hook-{$hook_type}"); |
|
| 245 | 245 | } |
| 246 | - restore_current_blog( $site_id ); |
|
| 246 | + restore_current_blog($site_id); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | } else { |
| 250 | 250 | |
| 251 | - foreach ( $hook_types as $hook_type ) { |
|
| 252 | - delete_option( "wordpoints_hook-{$hook_type}" ); |
|
| 251 | + foreach ($hook_types as $hook_type) { |
|
| 252 | + delete_option("wordpoints_hook-{$hook_type}"); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | // Sort the hooks by name. |
| 268 | 268 | $hook_types = self::$hook_types; |
| 269 | - uasort( $hook_types, array( __CLASS__, '_sort_name_callback' ) ); |
|
| 269 | + uasort($hook_types, array(__CLASS__, '_sort_name_callback')); |
|
| 270 | 270 | |
| 271 | 271 | $disabled_hooks = wordpoints_get_maybe_network_array_option( |
| 272 | 272 | 'wordpoints_legacy_points_hooks_disabled' |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | $i = 0; |
| 277 | 277 | |
| 278 | 278 | // Display a representative for each hook type. |
| 279 | - foreach ( $hook_types as $id_base => $hook_type ) { |
|
| 279 | + foreach ($hook_types as $id_base => $hook_type) { |
|
| 280 | 280 | |
| 281 | - if ( isset( $disabled_hooks[ $id_base ] ) ) { |
|
| 281 | + if (isset($disabled_hooks[$id_base])) { |
|
| 282 | 282 | continue; |
| 283 | 283 | } |
| 284 | 284 | |
@@ -291,16 +291,16 @@ discard block |
||
| 291 | 291 | $args['_multi_num'] = $hook_type->next_hook_id_number(); |
| 292 | 292 | $args['_id_slug'] = $i; |
| 293 | 293 | |
| 294 | - $hook_type->set_options( $args ); |
|
| 294 | + $hook_type->set_options($args); |
|
| 295 | 295 | |
| 296 | - self::_list_hook( $hook_type->get_id( 0 ), $hook_type ); |
|
| 296 | + self::_list_hook($hook_type->get_id(0), $hook_type); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // If there were none, give the user a message. |
| 300 | - if ( empty( $hook_types ) ) { |
|
| 300 | + if (empty($hook_types)) { |
|
| 301 | 301 | |
| 302 | 302 | echo '<div class="wordpoints-no-hooks">' |
| 303 | - . esc_html__( 'There are no points hooks currently available.', 'wordpoints' ) |
|
| 303 | + . esc_html__('There are no points hooks currently available.', 'wordpoints') |
|
| 304 | 304 | . '</div>'; |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -318,21 +318,21 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return void |
| 320 | 320 | */ |
| 321 | - public static function list_by_points_type( $slug ) { |
|
| 321 | + public static function list_by_points_type($slug) { |
|
| 322 | 322 | |
| 323 | - if ( '_inactive_hooks' !== $slug && ! wordpoints_is_points_type( $slug ) ) { |
|
| 323 | + if ('_inactive_hooks' !== $slug && ! wordpoints_is_points_type($slug)) { |
|
| 324 | 324 | return; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - $points_type_hooks = self::get_points_type_hooks( $slug ); |
|
| 327 | + $points_type_hooks = self::get_points_type_hooks($slug); |
|
| 328 | 328 | |
| 329 | - foreach ( $points_type_hooks as $hook_id ) { |
|
| 329 | + foreach ($points_type_hooks as $hook_id) { |
|
| 330 | 330 | |
| 331 | - list( $hook_type ) = explode( '-', $hook_id ); |
|
| 331 | + list($hook_type) = explode('-', $hook_id); |
|
| 332 | 332 | |
| 333 | - $hook_type = self::get_handler_by_id_base( $hook_type ); |
|
| 333 | + $hook_type = self::get_handler_by_id_base($hook_type); |
|
| 334 | 334 | |
| 335 | - if ( false === $hook_type ) { |
|
| 335 | + if (false === $hook_type) { |
|
| 336 | 336 | continue; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | $options['_display'] = 'instance'; |
| 342 | 342 | |
| 343 | - unset( $options['_add'] ); |
|
| 343 | + unset($options['_add']); |
|
| 344 | 344 | |
| 345 | 345 | $options['_id_slug'] = $slug; |
| 346 | 346 | |
| 347 | - $hook_type->set_options( $options ); |
|
| 347 | + $hook_type->set_options($options); |
|
| 348 | 348 | |
| 349 | - self::_list_hook( $hook_id, $hook_type, $slug ); |
|
| 349 | + self::_list_hook($hook_id, $hook_type, $slug); |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
@@ -362,9 +362,9 @@ discard block |
||
| 362 | 362 | * |
| 363 | 363 | * @param bool $on Whether to turn network mode on or off. |
| 364 | 364 | */ |
| 365 | - public static function set_network_mode( $on ) { |
|
| 365 | + public static function set_network_mode($on) { |
|
| 366 | 366 | |
| 367 | - if ( $on !== self::$network_mode ) { |
|
| 367 | + if ($on !== self::$network_mode) { |
|
| 368 | 368 | self::$network_mode = (bool) $on; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -408,12 +408,12 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @return array |
| 410 | 410 | */ |
| 411 | - public static function get_points_type_hooks( $slug ) { |
|
| 411 | + public static function get_points_type_hooks($slug) { |
|
| 412 | 412 | |
| 413 | 413 | $points_types_hooks = self::get_points_types_hooks(); |
| 414 | 414 | |
| 415 | - if ( isset( $points_types_hooks[ $slug ] ) && is_array( $points_types_hooks[ $slug ] ) ) { |
|
| 416 | - $points_type_hooks = $points_types_hooks[ $slug ]; |
|
| 415 | + if (isset($points_types_hooks[$slug]) && is_array($points_types_hooks[$slug])) { |
|
| 416 | + $points_type_hooks = $points_types_hooks[$slug]; |
|
| 417 | 417 | } else { |
| 418 | 418 | $points_type_hooks = array(); |
| 419 | 419 | } |
@@ -428,12 +428,12 @@ discard block |
||
| 428 | 428 | * |
| 429 | 429 | * @param array $points_types_hooks The list of points types and their hooks. |
| 430 | 430 | */ |
| 431 | - public static function save_points_types_hooks( array $points_types_hooks ) { |
|
| 431 | + public static function save_points_types_hooks(array $points_types_hooks) { |
|
| 432 | 432 | |
| 433 | - if ( self::$network_mode ) { |
|
| 434 | - update_site_option( 'wordpoints_points_types_hooks', $points_types_hooks ); |
|
| 433 | + if (self::$network_mode) { |
|
| 434 | + update_site_option('wordpoints_points_types_hooks', $points_types_hooks); |
|
| 435 | 435 | } else { |
| 436 | - update_option( 'wordpoints_points_types_hooks', $points_types_hooks ); |
|
| 436 | + update_option('wordpoints_points_types_hooks', $points_types_hooks); |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
@@ -446,11 +446,11 @@ discard block |
||
| 446 | 446 | * |
| 447 | 447 | * @return string|false The points type for the hook. False if not found. |
| 448 | 448 | */ |
| 449 | - public static function get_points_type( $hook_id ) { |
|
| 449 | + public static function get_points_type($hook_id) { |
|
| 450 | 450 | |
| 451 | - foreach ( self::get_points_types_hooks() as $points_type => $hooks ) { |
|
| 451 | + foreach (self::get_points_types_hooks() as $points_type => $hooks) { |
|
| 452 | 452 | |
| 453 | - if ( in_array( $hook_id, $hooks ) ) { |
|
| 453 | + if (in_array($hook_id, $hooks)) { |
|
| 454 | 454 | return $points_type; |
| 455 | 455 | } |
| 456 | 456 | } |
@@ -469,9 +469,9 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $defaults = array(); |
| 471 | 471 | |
| 472 | - foreach ( wordpoints_get_points_types() as $slug => $settings ) { |
|
| 472 | + foreach (wordpoints_get_points_types() as $slug => $settings) { |
|
| 473 | 473 | |
| 474 | - $defaults[ $slug ] = array(); |
|
| 474 | + $defaults[$slug] = array(); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | return $defaults; |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | * @param string $slug The slug for this type of points. |
| 497 | 497 | * @param string $wrap Whether to wrap the form inputs in a "widget" or not. |
| 498 | 498 | */ |
| 499 | - public static function points_type_form( $slug = null, $wrap = 'hook' ) { |
|
| 499 | + public static function points_type_form($slug = null, $wrap = 'hook') { |
|
| 500 | 500 | |
| 501 | 501 | _deprecated_function( |
| 502 | 502 | __METHOD__ |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | $add_new = 0; |
| 508 | 508 | |
| 509 | - $points_type = wordpoints_get_points_type( $slug ); |
|
| 509 | + $points_type = wordpoints_get_points_type($slug); |
|
| 510 | 510 | |
| 511 | - if ( ! $points_type ) { |
|
| 511 | + if ( ! $points_type) { |
|
| 512 | 512 | |
| 513 | 513 | $points_type = array(); |
| 514 | - $add_new = wp_create_nonce( 'wordpoints_add_new_points_type' ); |
|
| 514 | + $add_new = wp_create_nonce('wordpoints_add_new_points_type'); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | $points_type = array_merge( |
@@ -523,11 +523,11 @@ discard block |
||
| 523 | 523 | ,$points_type |
| 524 | 524 | ); |
| 525 | 525 | |
| 526 | - if ( ! isset( $slug ) && 'hook' === $wrap ) { |
|
| 526 | + if ( ! isset($slug) && 'hook' === $wrap) { |
|
| 527 | 527 | $wrap = 'hook-content'; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - switch ( $wrap ) { |
|
| 530 | + switch ($wrap) { |
|
| 531 | 531 | |
| 532 | 532 | case 'hook': |
| 533 | 533 | $hook_wrap = $hook_content_wrap = true; |
@@ -543,25 +543,25 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | ?> |
| 545 | 545 | |
| 546 | - <?php if ( $hook_wrap ) : ?> |
|
| 546 | + <?php if ($hook_wrap) : ?> |
|
| 547 | 547 | <div class="hook points-settings"> |
| 548 | 548 | <div class="hook-top"> |
| 549 | 549 | <div class="hook-title-action"> |
| 550 | 550 | <a class="hook-action hide-if-no-js" href="#available-hooks"></a> |
| 551 | 551 | </div> |
| 552 | - <div class="hook-title"><h3><?php esc_html_e( 'Settings', 'wordpoints' ); ?><span class="in-hook-title"></span></h3></div> |
|
| 552 | + <div class="hook-title"><h3><?php esc_html_e('Settings', 'wordpoints'); ?><span class="in-hook-title"></span></h3></div> |
|
| 553 | 553 | </div> |
| 554 | 554 | |
| 555 | 555 | <div class="hook-inside"> |
| 556 | 556 | <?php endif; ?> |
| 557 | 557 | |
| 558 | - <?php if ( $hook_content_wrap ) : ?> |
|
| 558 | + <?php if ($hook_content_wrap) : ?> |
|
| 559 | 559 | <form method="post"> |
| 560 | 560 | <div class="hook-content"> |
| 561 | 561 | <?php endif; ?> |
| 562 | 562 | |
| 563 | - <?php if ( $slug ) : ?> |
|
| 564 | - <p><span class="wordpoints-points-slug"><em><?php esc_html_e( 'Slug', 'wordpoints' ); ?>: <?php echo esc_html( $slug ); ?></em></span></p> |
|
| 563 | + <?php if ($slug) : ?> |
|
| 564 | + <p><span class="wordpoints-points-slug"><em><?php esc_html_e('Slug', 'wordpoints'); ?>: <?php echo esc_html($slug); ?></em></span></p> |
|
| 565 | 565 | <?php endif; ?> |
| 566 | 566 | |
| 567 | 567 | <?php |
@@ -575,33 +575,33 @@ discard block |
||
| 575 | 575 | * |
| 576 | 576 | * @param string $points_type The slug of the points type. |
| 577 | 577 | */ |
| 578 | - do_action( 'wordpoints_points_type_form_top', $slug ); |
|
| 578 | + do_action('wordpoints_points_type_form_top', $slug); |
|
| 579 | 579 | |
| 580 | - if ( 'hook-content' === $wrap ) { |
|
| 580 | + if ('hook-content' === $wrap) { |
|
| 581 | 581 | |
| 582 | 582 | // Mark the prefix and suffix optional on the add new form. |
| 583 | - $prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' ); |
|
| 584 | - $suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' ); |
|
| 583 | + $prefix = _x('Prefix (optional):', 'points type', 'wordpoints'); |
|
| 584 | + $suffix = _x('Suffix (optional):', 'points type', 'wordpoints'); |
|
| 585 | 585 | |
| 586 | 586 | } else { |
| 587 | 587 | |
| 588 | - $prefix = _x( 'Prefix:', 'points type', 'wordpoints' ); |
|
| 589 | - $suffix = _x( 'Suffix:', 'points type', 'wordpoints' ); |
|
| 588 | + $prefix = _x('Prefix:', 'points type', 'wordpoints'); |
|
| 589 | + $suffix = _x('Suffix:', 'points type', 'wordpoints'); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | ?> |
| 593 | 593 | |
| 594 | 594 | <p> |
| 595 | - <label for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label> |
|
| 596 | - <input class="widefat" type="text" id="points-name-<?php echo esc_attr( $slug ); ?>" name="points-name" value="<?php echo esc_attr( $points_type['name'] ); ?>" /> |
|
| 595 | + <label for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label> |
|
| 596 | + <input class="widefat" type="text" id="points-name-<?php echo esc_attr($slug); ?>" name="points-name" value="<?php echo esc_attr($points_type['name']); ?>" /> |
|
| 597 | 597 | </p> |
| 598 | 598 | <p> |
| 599 | - <label for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label> |
|
| 600 | - <input class="widefat" type="text" id="points-prefix-<?php echo esc_attr( $slug ); ?>" name="points-prefix" value="<?php echo esc_attr( $points_type['prefix'] ); ?>" /> |
|
| 599 | + <label for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label> |
|
| 600 | + <input class="widefat" type="text" id="points-prefix-<?php echo esc_attr($slug); ?>" name="points-prefix" value="<?php echo esc_attr($points_type['prefix']); ?>" /> |
|
| 601 | 601 | </p> |
| 602 | 602 | <p> |
| 603 | - <label for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label> |
|
| 604 | - <input class="widefat" type="text" id="points-suffix-<?php echo esc_attr( $slug ); ?>" name="points-suffix" value="<?php echo esc_attr( $points_type['suffix'] ); ?>" /> |
|
| 603 | + <label for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label> |
|
| 604 | + <input class="widefat" type="text" id="points-suffix-<?php echo esc_attr($slug); ?>" name="points-suffix" value="<?php echo esc_attr($points_type['suffix']); ?>" /> |
|
| 605 | 605 | </p> |
| 606 | 606 | |
| 607 | 607 | <?php |
@@ -615,30 +615,30 @@ discard block |
||
| 615 | 615 | * |
| 616 | 616 | * @param string $points_type The slug of the points type. |
| 617 | 617 | */ |
| 618 | - do_action( 'wordpoints_points_type_form_bottom', $slug ); |
|
| 618 | + do_action('wordpoints_points_type_form_bottom', $slug); |
|
| 619 | 619 | |
| 620 | 620 | ?> |
| 621 | 621 | |
| 622 | - <?php if ( $hook_content_wrap ) : ?> |
|
| 622 | + <?php if ($hook_content_wrap) : ?> |
|
| 623 | 623 | </div> |
| 624 | 624 | |
| 625 | - <input type="hidden" name="points-slug" value="<?php echo esc_attr( $slug ); ?>" /> |
|
| 626 | - <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr( $add_new ); ?>" /> |
|
| 625 | + <input type="hidden" name="points-slug" value="<?php echo esc_attr($slug); ?>" /> |
|
| 626 | + <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
|
| 627 | 627 | |
| 628 | 628 | <div class="hook-control-actions"> |
| 629 | 629 | <div class="alignleft"> |
| 630 | 630 | <?php |
| 631 | 631 | |
| 632 | - if ( ! $add_new ) { |
|
| 633 | - wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' ); |
|
| 634 | - submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) ); |
|
| 632 | + if ( ! $add_new) { |
|
| 633 | + wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce'); |
|
| 634 | + submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}")); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | ?> |
| 638 | - <a class="hook-control-close" href="#close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
| 638 | + <a class="hook-control-close" href="#close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
| 639 | 639 | </div> |
| 640 | 640 | <div class="alignright"> |
| 641 | - <?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?> |
|
| 641 | + <?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?> |
|
| 642 | 642 | <span class="spinner"></span> |
| 643 | 643 | </div> |
| 644 | 644 | <br class="clear" /> |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | </form> |
| 647 | 647 | <?php endif; ?> |
| 648 | 648 | |
| 649 | - <?php if ( $hook_wrap ) : ?> |
|
| 649 | + <?php if ($hook_wrap) : ?> |
|
| 650 | 650 | </div> |
| 651 | 651 | </div> |
| 652 | 652 | |
@@ -666,25 +666,25 @@ discard block |
||
| 666 | 666 | * @param WordPoints_Points_Hook $hook A points hook object. |
| 667 | 667 | * @param string $points_type The slug for a points type. |
| 668 | 668 | */ |
| 669 | - private static function _list_hook( $hook_id, $hook, $points_type = null ) { |
|
| 669 | + private static function _list_hook($hook_id, $hook, $points_type = null) { |
|
| 670 | 670 | |
| 671 | - $number = $hook->get_number_by_id( $hook_id ); |
|
| 671 | + $number = $hook->get_number_by_id($hook_id); |
|
| 672 | 672 | $id_base = $hook->get_id_base(); |
| 673 | 673 | $options = $hook->get_options(); |
| 674 | 674 | |
| 675 | 675 | $id_format = $hook_id; |
| 676 | 676 | |
| 677 | - $multi_number = ( isset( $options['_multi_num'] ) ) ? $options['_multi_num'] : ''; |
|
| 678 | - $add_new = ( isset( $options['_add'] ) ) ? $options['_add'] : ''; |
|
| 677 | + $multi_number = (isset($options['_multi_num'])) ? $options['_multi_num'] : ''; |
|
| 678 | + $add_new = (isset($options['_add'])) ? $options['_add'] : ''; |
|
| 679 | 679 | |
| 680 | 680 | // Prepare the URL query string. |
| 681 | - $query_arg = array( 'edithook' => $id_format ); |
|
| 681 | + $query_arg = array('edithook' => $id_format); |
|
| 682 | 682 | |
| 683 | - if ( $add_new ) { |
|
| 683 | + if ($add_new) { |
|
| 684 | 684 | |
| 685 | 685 | $query_arg['addnew'] = 1; |
| 686 | 686 | |
| 687 | - if ( $multi_number ) { |
|
| 687 | + if ($multi_number) { |
|
| 688 | 688 | |
| 689 | 689 | $query_arg['num'] = $multi_number; |
| 690 | 690 | $query_arg['base'] = $id_base; |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | $query_arg['points_type'] = $points_type; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if ( isset( $options['_display'] ) && 'template' === $options['_display'] ) { |
|
| 698 | + if (isset($options['_display']) && 'template' === $options['_display']) { |
|
| 699 | 699 | |
| 700 | 700 | /* |
| 701 | 701 | * We aren't outputting the form for a hook, but a template form for this |
@@ -711,40 +711,40 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | ?> |
| 713 | 713 | |
| 714 | - <div id="hook-<?php echo esc_html( $options['_id_slug'] ); ?>_<?php echo esc_attr( $id_format ); ?>" class="hook <?php echo esc_attr( $options['_classname'] ); ?>"> |
|
| 714 | + <div id="hook-<?php echo esc_html($options['_id_slug']); ?>_<?php echo esc_attr($id_format); ?>" class="hook <?php echo esc_attr($options['_classname']); ?>"> |
|
| 715 | 715 | <div class="hook-top"> |
| 716 | 716 | <div class="hook-title-action"> |
| 717 | 717 | <a class="hook-action hide-if-no-js" href="#available-hooks"></a> |
| 718 | - <a class="hook-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>"> |
|
| 719 | - <span class="edit"><?php echo esc_html_x( 'Edit', 'hook', 'wordpoints' ); ?></span> |
|
| 720 | - <span class="add"><?php echo esc_html_x( 'Add', 'hook', 'wordpoints' ); ?></span> |
|
| 721 | - <span class="screen-reader-text"><?php echo esc_html( strip_tags( $hook->get_name() ) ); ?></span> |
|
| 718 | + <a class="hook-control-edit hide-if-js" href="<?php echo esc_url(add_query_arg($query_arg)); ?>"> |
|
| 719 | + <span class="edit"><?php echo esc_html_x('Edit', 'hook', 'wordpoints'); ?></span> |
|
| 720 | + <span class="add"><?php echo esc_html_x('Add', 'hook', 'wordpoints'); ?></span> |
|
| 721 | + <span class="screen-reader-text"><?php echo esc_html(strip_tags($hook->get_name())); ?></span> |
|
| 722 | 722 | </a> |
| 723 | 723 | </div> |
| 724 | - <div class="hook-title"><h3><?php echo esc_html( strip_tags( $hook->get_name() ) ) ?><span class="in-hook-title"></span></h3></div> |
|
| 724 | + <div class="hook-title"><h3><?php echo esc_html(strip_tags($hook->get_name())) ?><span class="in-hook-title"></span></h3></div> |
|
| 725 | 725 | </div> |
| 726 | 726 | |
| 727 | 727 | <div class="hook-inside"> |
| 728 | 728 | <form method="post"> |
| 729 | 729 | <div class="hook-content"> |
| 730 | - <?php $has_form = $hook->form_callback( $number ); ?> |
|
| 730 | + <?php $has_form = $hook->form_callback($number); ?> |
|
| 731 | 731 | </div> |
| 732 | 732 | |
| 733 | - <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr( $id_format ); ?>" /> |
|
| 734 | - <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr( $id_base ); ?>" /> |
|
| 735 | - <input type="hidden" name="hook-width" class="hook-width" value="<?php echo isset( $options['width'] ) ? esc_attr( $options['width'] ) : ''; ?>" /> |
|
| 736 | - <input type="hidden" name="hook-height" class="hook-height" value="<?php echo isset( $options['height'] ) ? esc_attr( $options['height'] ) : ''; ?>" /> |
|
| 737 | - <input type="hidden" name="hook_number" class="hook_number" value="<?php echo esc_attr( $number ); ?>" /> |
|
| 738 | - <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr( $multi_number ); ?>" /> |
|
| 739 | - <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr( $add_new ); ?>" /> |
|
| 733 | + <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr($id_format); ?>" /> |
|
| 734 | + <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" /> |
|
| 735 | + <input type="hidden" name="hook-width" class="hook-width" value="<?php echo isset($options['width']) ? esc_attr($options['width']) : ''; ?>" /> |
|
| 736 | + <input type="hidden" name="hook-height" class="hook-height" value="<?php echo isset($options['height']) ? esc_attr($options['height']) : ''; ?>" /> |
|
| 737 | + <input type="hidden" name="hook_number" class="hook_number" value="<?php echo esc_attr($number); ?>" /> |
|
| 738 | + <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" /> |
|
| 739 | + <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
|
| 740 | 740 | |
| 741 | 741 | <div class="hook-control-actions"> |
| 742 | 742 | <div class="alignleft"> |
| 743 | - <a class="hook-control-remove" href="#remove"><?php esc_html_e( 'Delete', 'wordpoints' ); ?></a> | |
|
| 744 | - <a class="hook-control-close" href="#close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
| 743 | + <a class="hook-control-remove" href="#remove"><?php esc_html_e('Delete', 'wordpoints'); ?></a> | |
|
| 744 | + <a class="hook-control-close" href="#close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
| 745 | 745 | </div> |
| 746 | - <div class="alignright<?php echo ( false === $has_form ) ? ' hook-control-noform' : ''; ?>"> |
|
| 747 | - <?php submit_button( __( 'Save', 'wordpoints' ), 'button-primary hook-control-save right', 'savehook', false, array( 'id' => "hook-{$id_format}-savehook" ) ); ?> |
|
| 746 | + <div class="alignright<?php echo (false === $has_form) ? ' hook-control-noform' : ''; ?>"> |
|
| 747 | + <?php submit_button(__('Save', 'wordpoints'), 'button-primary hook-control-save right', 'savehook', false, array('id' => "hook-{$id_format}-savehook")); ?> |
|
| 748 | 748 | <span class="spinner"></span> |
| 749 | 749 | </div> |
| 750 | 750 | <br class="clear" /> |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | </div> |
| 754 | 754 | |
| 755 | 755 | <div class="hook-description"> |
| 756 | - <?php if ( ! empty( $options['description'] ) ) : ?> |
|
| 757 | - <?php echo esc_html( $options['description'] ); ?> |
|
| 756 | + <?php if ( ! empty($options['description'])) : ?> |
|
| 757 | + <?php echo esc_html($options['description']); ?> |
|
| 758 | 758 | <?php endif; ?> |
| 759 | 759 | </div> |
| 760 | 760 | </div> |
@@ -774,9 +774,9 @@ discard block |
||
| 774 | 774 | * |
| 775 | 775 | * @return int |
| 776 | 776 | */ |
| 777 | - private static function _sort_name_callback( $a, $b ) { |
|
| 777 | + private static function _sort_name_callback($a, $b) { |
|
| 778 | 778 | |
| 779 | - return strnatcasecmp( $a->get_name(), $b->get_name() ); |
|
| 779 | + return strnatcasecmp($a->get_name(), $b->get_name()); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | } // class WordPoints_Points_Hooks |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected function verify_atts() { |
| 26 | 26 | |
| 27 | - if ( isset( $this->pairs['points_type'] ) ) { |
|
| 27 | + if (isset($this->pairs['points_type'])) { |
|
| 28 | 28 | |
| 29 | 29 | $points_type = $this->get_points_type(); |
| 30 | 30 | |
| 31 | - if ( is_wp_error( $points_type ) ) { |
|
| 31 | + if (is_wp_error($points_type)) { |
|
| 32 | 32 | return $points_type; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $points_type = $this->atts['points_type']; |
| 56 | 56 | |
| 57 | - if ( ! wordpoints_is_points_type( $points_type ) ) { |
|
| 57 | + if ( ! wordpoints_is_points_type($points_type)) { |
|
| 58 | 58 | |
| 59 | 59 | $points_type = wordpoints_get_default_points_type(); |
| 60 | 60 | |
| 61 | - if ( ! $points_type ) { |
|
| 61 | + if ( ! $points_type) { |
|
| 62 | 62 | |
| 63 | 63 | $points_type = new WP_Error( |
| 64 | 64 | 'wordpoints_shortcode_no_points_type' |
| 65 | 65 | , sprintf( |
| 66 | - __( 'The “%1$s” attribute of the %2$s shortcode must be the slug of a points type. Example: %3$s.', 'wordpoints' ) |
|
| 66 | + __('The “%1$s” attribute of the %2$s shortcode must be the slug of a points type. Example: %3$s.', 'wordpoints') |
|
| 67 | 67 | , 'points_type' |
| 68 | - , '<code>[' . sanitize_key( $this->shortcode ) . ']</code>' |
|
| 69 | - , '<code>[' . sanitize_key( $this->shortcode ) . ' points_type="points"]</code>' |
|
| 68 | + , '<code>[' . sanitize_key($this->shortcode) . ']</code>' |
|
| 69 | + , '<code>[' . sanitize_key($this->shortcode) . ' points_type="points"]</code>' |
|
| 70 | 70 | ) |
| 71 | 71 | ); |
| 72 | 72 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param array $atts The shortcode attributes. |
| 82 | 82 | * @param string $shortcode The shortcode. |
| 83 | 83 | */ |
| 84 | - return apply_filters( 'wordpoints_shortcode_points_type', $points_type, $this->atts, $this->shortcode ); |
|
| 84 | + return apply_filters('wordpoints_shortcode_points_type', $points_type, $this->atts, $this->shortcode); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | protected function verify_atts() { |
| 112 | 112 | |
| 113 | - if ( ! wordpoints_posint( $this->atts['users'] ) ) { |
|
| 113 | + if ( ! wordpoints_posint($this->atts['users'])) { |
|
| 114 | 114 | return sprintf( |
| 115 | - __( 'The “%1$s” attribute of the %2$s shortcode must be a positive integer. Example: %3$s.', 'wordpoints' ) |
|
| 115 | + __('The “%1$s” attribute of the %2$s shortcode must be a positive integer. Example: %3$s.', 'wordpoints') |
|
| 116 | 116 | , 'users' |
| 117 | - , '<code>[' . sanitize_key( $this->shortcode ) . ']</code>' |
|
| 118 | - , '<code>[' . sanitize_key( $this->shortcode ) . ' <b>users="10"</b> type="points"]</code>' |
|
| 117 | + , '<code>[' . sanitize_key($this->shortcode) . ']</code>' |
|
| 118 | + , '<code>[' . sanitize_key($this->shortcode) . ' <b>users="10"</b> type="points"]</code>' |
|
| 119 | 119 | ); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -167,25 +167,25 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | protected function verify_atts() { |
| 169 | 169 | |
| 170 | - if ( ! wordpoints_is_points_logs_query( $this->atts['query'] ) ) { |
|
| 170 | + if ( ! wordpoints_is_points_logs_query($this->atts['query'])) { |
|
| 171 | 171 | return sprintf( |
| 172 | - __( 'The “%1$s” attribute of the %2$s shortcode must be the slug of a registered points log query. Example: %3$s.', 'wordpoints' ) |
|
| 172 | + __('The “%1$s” attribute of the %2$s shortcode must be the slug of a registered points log query. Example: %3$s.', 'wordpoints') |
|
| 173 | 173 | , 'query' |
| 174 | - , '<code>[' . sanitize_key( $this->shortcode ) . ']</code>' |
|
| 175 | - , '<code>[' . sanitize_key( $this->shortcode ) . ' <b>query="default"</b> points_type="points"]</code>' |
|
| 174 | + , '<code>[' . sanitize_key($this->shortcode) . ']</code>' |
|
| 175 | + , '<code>[' . sanitize_key($this->shortcode) . ' <b>query="default"</b> points_type="points"]</code>' |
|
| 176 | 176 | ); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( false === wordpoints_int( $this->atts['paginate'] ) ) { |
|
| 179 | + if (false === wordpoints_int($this->atts['paginate'])) { |
|
| 180 | 180 | $this->atts['paginate'] = 1; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Back-compat. Needs to stay here "forever" for legacy installs. |
| 184 | - if ( isset( $this->atts['datatables'] ) ) { |
|
| 185 | - $this->atts['paginate'] = wordpoints_int( $this->atts['datatables'] ); |
|
| 184 | + if (isset($this->atts['datatables'])) { |
|
| 185 | + $this->atts['paginate'] = wordpoints_int($this->atts['datatables']); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if ( false === wordpoints_int( $this->atts['show_users'] ) ) { |
|
| 188 | + if (false === wordpoints_int($this->atts['show_users'])) { |
|
| 189 | 189 | $this->atts['show_users'] = 1; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -277,34 +277,34 @@ discard block |
||
| 277 | 277 | * @param string[] $extra_classes The extra classes for the table element. |
| 278 | 278 | * @param array $atts The arguments for table display from the shortcode. |
| 279 | 279 | */ |
| 280 | - $extra_classes = apply_filters( 'wordpoints_how_to_get_points_table_extra_classes', array(), $this->atts ); |
|
| 280 | + $extra_classes = apply_filters('wordpoints_how_to_get_points_table_extra_classes', array(), $this->atts); |
|
| 281 | 281 | |
| 282 | - $points_heading = _x( 'Points', 'column name', 'wordpoints' ); |
|
| 282 | + $points_heading = _x('Points', 'column name', 'wordpoints'); |
|
| 283 | 283 | |
| 284 | 284 | $points_type_name = wordpoints_get_points_type_setting( |
| 285 | 285 | $this->atts['points_type'] |
| 286 | 286 | , 'name' |
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | - if ( ! empty( $points_type_name ) ) { |
|
| 289 | + if ( ! empty($points_type_name)) { |
|
| 290 | 290 | $points_heading = $points_type_name; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $html = '<table class="wordpoints-how-to-get-points ' . esc_attr( implode( ' ', $extra_classes ) ) . '"> |
|
| 293 | + $html = '<table class="wordpoints-how-to-get-points ' . esc_attr(implode(' ', $extra_classes)) . '"> |
|
| 294 | 294 | <thead> |
| 295 | - <tr><th style="padding-right: 10px">' . esc_html( $points_heading ) . '</th> |
|
| 296 | - <th>' . esc_html_x( 'Action', 'column name', 'wordpoints' ) . '</th></tr> |
|
| 295 | + <tr><th style="padding-right: 10px">' . esc_html($points_heading) . '</th> |
|
| 296 | + <th>' . esc_html_x('Action', 'column name', 'wordpoints') . '</th></tr> |
|
| 297 | 297 | </thead> |
| 298 | 298 | <tbody>'; |
| 299 | 299 | |
| 300 | - $html .= $this->list_reactions( 'points' ); |
|
| 300 | + $html .= $this->list_reactions('points'); |
|
| 301 | 301 | $html .= $this->list_points_hooks(); |
| 302 | 302 | |
| 303 | - if ( is_wordpoints_network_active() ) { |
|
| 303 | + if (is_wordpoints_network_active()) { |
|
| 304 | 304 | |
| 305 | - WordPoints_Points_Hooks::set_network_mode( true ); |
|
| 305 | + WordPoints_Points_Hooks::set_network_mode(true); |
|
| 306 | 306 | $html .= $this->list_points_hooks(); |
| 307 | - WordPoints_Points_Hooks::set_network_mode( false ); |
|
| 307 | + WordPoints_Points_Hooks::set_network_mode(false); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | $html .= '</tbody></table>'; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | $network = ''; |
| 325 | 325 | |
| 326 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
| 326 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
| 327 | 327 | $network = 'network_'; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -333,17 +333,17 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $html = ''; |
| 335 | 335 | |
| 336 | - foreach ( $hooks as $hook_id ) { |
|
| 336 | + foreach ($hooks as $hook_id) { |
|
| 337 | 337 | |
| 338 | - $hook = WordPoints_Points_Hooks::get_handler( $hook_id ); |
|
| 338 | + $hook = WordPoints_Points_Hooks::get_handler($hook_id); |
|
| 339 | 339 | |
| 340 | - if ( ! $hook ) { |
|
| 340 | + if ( ! $hook) { |
|
| 341 | 341 | continue; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $points = $hook->get_points( $network . $hook->get_number() ); |
|
| 344 | + $points = $hook->get_points($network . $hook->get_number()); |
|
| 345 | 345 | |
| 346 | - if ( ! $points ) { |
|
| 346 | + if ( ! $points) { |
|
| 347 | 347 | continue; |
| 348 | 348 | } |
| 349 | 349 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | $html .= '<tr> |
| 357 | 357 | <td>' . $points . '</td> |
| 358 | - <td>' . esc_html( $hook->get_description() ) . '</td> |
|
| 358 | + <td>' . esc_html($hook->get_description()) . '</td> |
|
| 359 | 359 | </tr>'; |
| 360 | 360 | } |
| 361 | 361 | |
@@ -374,21 +374,21 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * @return string The HTML for the table rows. |
| 376 | 376 | */ |
| 377 | - protected function list_reactions( $store_slug ) { |
|
| 377 | + protected function list_reactions($store_slug) { |
|
| 378 | 378 | |
| 379 | 379 | $html = ''; |
| 380 | 380 | |
| 381 | - foreach ( wordpoints_hooks()->get_reaction_stores( $store_slug ) as $store ) { |
|
| 381 | + foreach (wordpoints_hooks()->get_reaction_stores($store_slug) as $store) { |
|
| 382 | 382 | |
| 383 | - foreach ( $store->get_reactions() as $reaction ) { |
|
| 383 | + foreach ($store->get_reactions() as $reaction) { |
|
| 384 | 384 | |
| 385 | - if ( $reaction->get_meta( 'points_type' ) !== $this->atts['points_type'] ) { |
|
| 385 | + if ($reaction->get_meta('points_type') !== $this->atts['points_type']) { |
|
| 386 | 386 | continue; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - $points = $reaction->get_meta( 'points' ); |
|
| 389 | + $points = $reaction->get_meta('points'); |
|
| 390 | 390 | |
| 391 | - if ( ! $points ) { |
|
| 391 | + if ( ! $points) { |
|
| 392 | 392 | continue; |
| 393 | 393 | } |
| 394 | 394 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | $html .= '<tr> |
| 402 | 402 | <td>' . $points . '</td> |
| 403 | - <td>' . esc_html( $reaction->get_meta( 'description' ) ) . '</td> |
|
| 403 | + <td>' . esc_html($reaction->get_meta('description')) . '</td> |
|
| 404 | 404 | </tr>'; |
| 405 | 405 | } |
| 406 | 406 | } |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | -function wordpoints_points_top_shortcode( $atts ) { |
|
| 25 | +function wordpoints_points_top_shortcode($atts) { |
|
| 26 | 26 | |
| 27 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
| 27 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
| 28 | 28 | |
| 29 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_points_top' ); |
|
| 29 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_points_top'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | -function wordpoints_points_logs_shortcode( $atts ) { |
|
| 54 | +function wordpoints_points_logs_shortcode($atts) { |
|
| 55 | 55 | |
| 56 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
| 56 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
| 57 | 57 | |
| 58 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_points_logs' ); |
|
| 58 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_points_logs'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return string The points for the user. |
| 78 | 78 | */ |
| 79 | -function wordpoints_points_shortcode( $atts ) { |
|
| 79 | +function wordpoints_points_shortcode($atts) { |
|
| 80 | 80 | |
| 81 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
| 81 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
| 82 | 82 | |
| 83 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_points' ); |
|
| 83 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_points'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return string A list of points hooks describing how the user can earn points. |
| 99 | 99 | */ |
| 100 | -function wordpoints_how_to_get_points_shortcode( $atts ) { |
|
| 100 | +function wordpoints_how_to_get_points_shortcode($atts) { |
|
| 101 | 101 | |
| 102 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
| 102 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
| 103 | 103 | |
| 104 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_how_to_get_points' ); |
|
| 104 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_how_to_get_points'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @type array $defaults |
| 125 | 125 | */ |
| 126 | - protected $defaults = array( 'points' => 10, 'post_type' => 'ALL' ); |
|
| 126 | + protected $defaults = array('points' => 10, 'post_type' => 'ALL'); |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Initialize the hook. |
@@ -132,23 +132,23 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function __construct() { |
| 134 | 134 | |
| 135 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
| 136 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 135 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
| 136 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $this->init( |
| 140 | - _x( 'Comment Removed', 'points hook name', 'wordpoints' ) |
|
| 140 | + _x('Comment Removed', 'points hook name', 'wordpoints') |
|
| 141 | 141 | , array( |
| 142 | - 'description' => __( 'Comment removed from the site.', 'wordpoints' ), |
|
| 142 | + 'description' => __('Comment removed from the site.', 'wordpoints'), |
|
| 143 | 143 | /* translators: the post type name. */ |
| 144 | - 'post_type_description' => __( 'Comment on a %s removed from the site.', 'wordpoints' ), |
|
| 145 | - 'post_type_filter' => array( $this, 'post_type_supports_comments' ), |
|
| 146 | - 'points_label' => __( 'Points subtracted if comment removed:', 'wordpoints' ), |
|
| 144 | + 'post_type_description' => __('Comment on a %s removed from the site.', 'wordpoints'), |
|
| 145 | + 'post_type_filter' => array($this, 'post_type_supports_comments'), |
|
| 146 | + 'points_label' => __('Points subtracted if comment removed:', 'wordpoints'), |
|
| 147 | 147 | ) |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | - add_action( 'transition_comment_status', array( $this, 'hook' ), 10, 3 ); |
|
| 151 | - add_filter( 'wordpoints_points_log-comment_disapprove', array( $this, 'logs' ), 10, 6 ); |
|
| 150 | + add_action('transition_comment_status', array($this, 'hook'), 10, 3); |
|
| 151 | + add_filter('wordpoints_points_log-comment_disapprove', array($this, 'logs'), 10, 6); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -166,36 +166,36 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | - public function hook( $new_status, $old_status, $comment ) { |
|
| 169 | + public function hook($new_status, $old_status, $comment) { |
|
| 170 | 170 | |
| 171 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
| 172 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 171 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
| 172 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( ! $comment->user_id || $old_status === $new_status ) { |
|
| 175 | + if ( ! $comment->user_id || $old_status === $new_status) { |
|
| 176 | 176 | return; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $post = get_post( $comment->comment_post_ID ); |
|
| 179 | + $post = get_post($comment->comment_post_ID); |
|
| 180 | 180 | |
| 181 | - if ( 'approved' === $old_status ) { |
|
| 181 | + if ('approved' === $old_status) { |
|
| 182 | 182 | |
| 183 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
| 183 | + foreach ($this->get_instances() as $number => $instance) { |
|
| 184 | 184 | |
| 185 | - $instance = array_merge( $this->defaults, $instance ); |
|
| 185 | + $instance = array_merge($this->defaults, $instance); |
|
| 186 | 186 | |
| 187 | - if ( ! $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) ) { |
|
| 187 | + if ( ! $this->is_matching_post_type($post->post_type, $instance['post_type'])) { |
|
| 188 | 188 | continue; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $points_type = $this->points_type( $number ); |
|
| 191 | + $points_type = $this->points_type($number); |
|
| 192 | 192 | |
| 193 | - wordpoints_subtract_points( $comment->user_id, $instance['points'], $points_type, 'comment_disapprove', array( 'status' => $new_status ) ); |
|
| 193 | + wordpoints_subtract_points($comment->user_id, $instance['points'], $points_type, 'comment_disapprove', array('status' => $new_status)); |
|
| 194 | 194 | |
| 195 | 195 | update_comment_meta( |
| 196 | 196 | $comment->comment_ID |
| 197 | - , wp_slash( "wordpoints_last_status-{$points_type}" ) |
|
| 198 | - , wp_slash( $new_status ) |
|
| 197 | + , wp_slash("wordpoints_last_status-{$points_type}") |
|
| 198 | + , wp_slash($new_status) |
|
| 199 | 199 | ); |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -220,17 +220,17 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return void |
| 222 | 222 | */ |
| 223 | - public function new_comment_hook( $comment_id, $comment ) { |
|
| 223 | + public function new_comment_hook($comment_id, $comment) { |
|
| 224 | 224 | |
| 225 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
| 226 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 225 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
| 226 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( 0 === (int) $comment->user_id ) { |
|
| 229 | + if (0 === (int) $comment->user_id) { |
|
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - switch ( $comment->comment_approved ) { |
|
| 233 | + switch ($comment->comment_approved) { |
|
| 234 | 234 | |
| 235 | 235 | // Comment hasn't been approved yet. |
| 236 | 236 | case 0: return; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $old_status = 'approved'; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $this->hook( $new_status, $old_status, $comment ); |
|
| 247 | + $this->hook($new_status, $old_status, $comment); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
| 266 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
| 267 | 267 | |
| 268 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
| 269 | - _deprecated_function( __METHOD__, '1.9.0', 'wordpoints_points_logs_comment_disapprove' ); |
|
| 268 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
| 269 | + _deprecated_function(__METHOD__, '1.9.0', 'wordpoints_points_logs_comment_disapprove'); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | return wordpoints_points_logs_comment_disapprove( |
@@ -288,15 +288,15 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @return int|false The number of points, or false. |
| 290 | 290 | */ |
| 291 | - public function get_points( $number = null ) { |
|
| 291 | + public function get_points($number = null) { |
|
| 292 | 292 | |
| 293 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
| 294 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 293 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
| 294 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - $points = parent::get_points( $number ); |
|
| 297 | + $points = parent::get_points($number); |
|
| 298 | 298 | |
| 299 | - if ( $points ) { |
|
| 299 | + if ($points) { |
|
| 300 | 300 | $points = -$points; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * |
| 323 | 323 | * @type array $defaults |
| 324 | 324 | */ |
| 325 | - protected $defaults = array( 'points' => 20, 'post_type' => 'ALL' ); |
|
| 325 | + protected $defaults = array('points' => 20, 'post_type' => 'ALL'); |
|
| 326 | 326 | |
| 327 | 327 | // |
| 328 | 328 | // Public Methods. |
@@ -335,22 +335,22 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function __construct() { |
| 337 | 337 | |
| 338 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
| 339 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 338 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
| 339 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | $this->init( |
| 343 | - _x( 'Post Delete', 'points hook name', 'wordpoints' ) |
|
| 343 | + _x('Post Delete', 'points hook name', 'wordpoints') |
|
| 344 | 344 | ,array( |
| 345 | - 'description' => __( 'A post is permanently deleted.', 'wordpoints' ), |
|
| 346 | - 'points_label' => __( 'Points removed when deleted:', 'wordpoints' ), |
|
| 345 | + 'description' => __('A post is permanently deleted.', 'wordpoints'), |
|
| 346 | + 'points_label' => __('Points removed when deleted:', 'wordpoints'), |
|
| 347 | 347 | /* translators: the post type name. */ |
| 348 | - 'post_type_description' => __( '%s permanently deleted.', 'wordpoints' ), |
|
| 348 | + 'post_type_description' => __('%s permanently deleted.', 'wordpoints'), |
|
| 349 | 349 | ) |
| 350 | 350 | ); |
| 351 | 351 | |
| 352 | - add_action( 'delete_post', array( $this, 'hook' ) ); |
|
| 353 | - add_filter( 'wordpoints_points_log-post_delete', array( $this, 'logs' ), 10, 6 ); |
|
| 352 | + add_action('delete_post', array($this, 'hook')); |
|
| 353 | + add_filter('wordpoints_points_log-post_delete', array($this, 'logs'), 10, 6); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
@@ -362,30 +362,30 @@ discard block |
||
| 362 | 362 | * |
| 363 | 363 | * @param int $post_id The post's ID. |
| 364 | 364 | */ |
| 365 | - public function hook( $post_id ) { |
|
| 365 | + public function hook($post_id) { |
|
| 366 | 366 | |
| 367 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
| 368 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 367 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
| 368 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - $post = get_post( $post_id, OBJECT, 'display' ); |
|
| 371 | + $post = get_post($post_id, OBJECT, 'display'); |
|
| 372 | 372 | |
| 373 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
| 373 | + foreach ($this->get_instances() as $number => $instance) { |
|
| 374 | 374 | |
| 375 | - $instance = array_merge( $this->defaults, $instance ); |
|
| 375 | + $instance = array_merge($this->defaults, $instance); |
|
| 376 | 376 | |
| 377 | 377 | if ( |
| 378 | - $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) |
|
| 378 | + $this->is_matching_post_type($post->post_type, $instance['post_type']) |
|
| 379 | 379 | && 'auto-draft' !== $post->post_status |
| 380 | - && __( 'Auto Draft', 'default' ) !== $post->post_title |
|
| 380 | + && __('Auto Draft', 'default') !== $post->post_title |
|
| 381 | 381 | ) { |
| 382 | 382 | |
| 383 | 383 | wordpoints_alter_points( |
| 384 | 384 | $post->post_author |
| 385 | 385 | , -$instance['points'] |
| 386 | - , $this->points_type( $number ) |
|
| 386 | + , $this->points_type($number) |
|
| 387 | 387 | , 'post_delete' |
| 388 | - , array( 'post_title' => $post->post_title, 'post_type' => $post->post_type ) |
|
| 388 | + , array('post_title' => $post->post_title, 'post_type' => $post->post_type) |
|
| 389 | 389 | ); |
| 390 | 390 | } |
| 391 | 391 | } |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | * |
| 410 | 410 | * @return string |
| 411 | 411 | */ |
| 412 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
| 412 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
| 413 | 413 | |
| 414 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
| 415 | - _deprecated_function( __METHOD__, '1.9.0', 'wordpoints_points_logs_post_delete' ); |
|
| 414 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
| 415 | + _deprecated_function(__METHOD__, '1.9.0', 'wordpoints_points_logs_post_delete'); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | return wordpoints_points_logs_post_delete( |
@@ -434,15 +434,15 @@ discard block |
||
| 434 | 434 | * |
| 435 | 435 | * @return int|false The number of points, or false. |
| 436 | 436 | */ |
| 437 | - public function get_points( $number = null ) { |
|
| 437 | + public function get_points($number = null) { |
|
| 438 | 438 | |
| 439 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
| 440 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
| 439 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
| 440 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - $points = parent::get_points( $number ); |
|
| 443 | + $points = parent::get_points($number); |
|
| 444 | 444 | |
| 445 | - if ( $points ) { |
|
| 445 | + if ($points) { |
|
| 446 | 446 | $points = -$points; |
| 447 | 447 | } |
| 448 | 448 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | */ |
| 462 | 462 | function wordpoints_points_get_db_schema() { |
| 463 | 463 | |
| 464 | - _deprecated_function( __FUNCTION__, '2.0.0' ); |
|
| 464 | + _deprecated_function(__FUNCTION__, '2.0.0'); |
|
| 465 | 465 | |
| 466 | 466 | global $wpdb; |
| 467 | 467 | |
@@ -500,16 +500,16 @@ discard block |
||
| 500 | 500 | * |
| 501 | 501 | * @param int $blog_id The ID of the new site. |
| 502 | 502 | */ |
| 503 | -function wordpoints_points_add_custom_caps_to_new_sites( $blog_id ) { |
|
| 503 | +function wordpoints_points_add_custom_caps_to_new_sites($blog_id) { |
|
| 504 | 504 | |
| 505 | - _deprecated_function( __FUNCTION__, '2.0.0' ); |
|
| 505 | + _deprecated_function(__FUNCTION__, '2.0.0'); |
|
| 506 | 506 | |
| 507 | - if ( ! is_wordpoints_network_active() ) { |
|
| 507 | + if ( ! is_wordpoints_network_active()) { |
|
| 508 | 508 | return; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - switch_to_blog( $blog_id ); |
|
| 512 | - wordpoints_add_custom_caps( wordpoints_points_get_custom_caps() ); |
|
| 511 | + switch_to_blog($blog_id); |
|
| 512 | + wordpoints_add_custom_caps(wordpoints_points_get_custom_caps()); |
|
| 513 | 513 | restore_current_blog(); |
| 514 | 514 | } |
| 515 | 515 | |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
| 18 | 18 | */ |
| 19 | -function wordpoints_points_hook_reactors_init( $reactors ) { |
|
| 19 | +function wordpoints_points_hook_reactors_init($reactors) { |
|
| 20 | 20 | |
| 21 | - $reactors->register( 'points', 'WordPoints_Points_Hook_Reactor' ); |
|
| 22 | - $reactors->register( 'points_legacy', 'WordPoints_Points_Hook_Reactor_Legacy' ); |
|
| 21 | + $reactors->register('points', 'WordPoints_Points_Hook_Reactor'); |
|
| 22 | + $reactors->register('points_legacy', 'WordPoints_Points_Hook_Reactor_Legacy'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param WordPoints_Class_Registry_Children $reaction_stores The store registry. |
| 33 | 33 | */ |
| 34 | -function wordpoints_points_hook_reaction_stores_init( $reaction_stores ) { |
|
| 34 | +function wordpoints_points_hook_reaction_stores_init($reaction_stores) { |
|
| 35 | 35 | |
| 36 | 36 | $reaction_stores->register( |
| 37 | 37 | 'standard' |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | , 'WordPoints_Hook_Reaction_Store_Options' |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - if ( is_wordpoints_network_active() ) { |
|
| 42 | + if (is_wordpoints_network_active()) { |
|
| 43 | 43 | $reaction_stores->register( |
| 44 | 44 | 'network' |
| 45 | 45 | , 'points' |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
| 59 | 59 | */ |
| 60 | -function wordpoints_points_hook_extensions_init( $extensions ) { |
|
| 60 | +function wordpoints_points_hook_extensions_init($extensions) { |
|
| 61 | 61 | |
| 62 | 62 | $extensions->register( |
| 63 | 63 | 'points_legacy_reversals' |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param string $slug The slug of the post type. |
| 87 | 87 | */ |
| 88 | -function wordpoints_points_register_legacy_post_publish_events( $slug ) { |
|
| 88 | +function wordpoints_points_register_legacy_post_publish_events($slug) { |
|
| 89 | 89 | |
| 90 | - if ( 'attachment' === $slug ) { |
|
| 90 | + if ('attachment' === $slug) { |
|
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $events = wordpoints_hooks()->get_sub_app( 'events' ); |
|
| 94 | + $events = wordpoints_hooks()->get_sub_app('events'); |
|
| 95 | 95 | |
| 96 | 96 | $events->register( |
| 97 | 97 | "points_legacy_post_publish\\{$slug}" |
@@ -131,19 +131,19 @@ discard block |
||
| 131 | 131 | wp_register_style( |
| 132 | 132 | 'wordpoints-points-logs' |
| 133 | 133 | , "{$assets_url}/css/points-logs{$suffix}.css" |
| 134 | - , array( 'dashicons' ) |
|
| 134 | + , array('dashicons') |
|
| 135 | 135 | , WORDPOINTS_VERSION |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | 138 | $styles = wp_styles(); |
| 139 | - $rtl_styles = array( 'wordpoints-top-users', 'wordpoints-points-logs' ); |
|
| 139 | + $rtl_styles = array('wordpoints-top-users', 'wordpoints-points-logs'); |
|
| 140 | 140 | |
| 141 | - foreach ( $rtl_styles as $rtl_style ) { |
|
| 141 | + foreach ($rtl_styles as $rtl_style) { |
|
| 142 | 142 | |
| 143 | - $styles->add_data( $rtl_style, 'rtl', 'replace' ); |
|
| 143 | + $styles->add_data($rtl_style, 'rtl', 'replace'); |
|
| 144 | 144 | |
| 145 | - if ( $suffix ) { |
|
| 146 | - $styles->add_data( $rtl_style, 'suffix', $suffix ); |
|
| 145 | + if ($suffix) { |
|
| 146 | + $styles->add_data($rtl_style, 'suffix', $suffix); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | return array( |
| 161 | 161 | 'set_wordpoints_points' => 'manage_options', |
| 162 | 162 | 'manage_network_wordpoints_points_hooks' => 'manage_network_options', |
| 163 | - 'manage_wordpoints_points_types' => ( is_wordpoints_network_active() ) ? 'manage_network_options' : 'manage_options', |
|
| 163 | + 'manage_wordpoints_points_types' => (is_wordpoints_network_active()) ? 'manage_network_options' : 'manage_options', |
|
| 164 | 164 | ); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -178,23 +178,23 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return string $points formatted with prefix and suffix. |
| 180 | 180 | */ |
| 181 | -function wordpoints_format_points_filter( $formatted, $points, $type ) { |
|
| 181 | +function wordpoints_format_points_filter($formatted, $points, $type) { |
|
| 182 | 182 | |
| 183 | - $points_type = wordpoints_get_points_type( $type ); |
|
| 183 | + $points_type = wordpoints_get_points_type($type); |
|
| 184 | 184 | |
| 185 | - if ( isset( $points_type['prefix'] ) ) { |
|
| 185 | + if (isset($points_type['prefix'])) { |
|
| 186 | 186 | |
| 187 | - if ( $points < 0 ) { |
|
| 187 | + if ($points < 0) { |
|
| 188 | 188 | |
| 189 | - $points = abs( $points ); |
|
| 189 | + $points = abs($points); |
|
| 190 | 190 | $points_type['prefix'] = '-' . $points_type['prefix']; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $formatted = esc_html( $points_type['prefix'] . $points ); |
|
| 193 | + $formatted = esc_html($points_type['prefix'] . $points); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if ( isset( $points_type['suffix'] ) ) { |
|
| 197 | - $formatted = $formatted . esc_html( $points_type['suffix'] ); |
|
| 196 | + if (isset($points_type['suffix'])) { |
|
| 197 | + $formatted = $formatted . esc_html($points_type['suffix']); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | return $formatted; |
@@ -211,20 +211,20 @@ discard block |
||
| 211 | 211 | * @param array $args The arguments for the dropdown {@see |
| 212 | 212 | * WordPoints_Dropdown_Builder::$args}. |
| 213 | 213 | */ |
| 214 | -function wordpoints_points_types_dropdown( array $args ) { |
|
| 214 | +function wordpoints_points_types_dropdown(array $args) { |
|
| 215 | 215 | |
| 216 | 216 | $points_types = array(); |
| 217 | 217 | |
| 218 | - foreach ( wordpoints_get_points_types() as $slug => $settings ) { |
|
| 218 | + foreach (wordpoints_get_points_types() as $slug => $settings) { |
|
| 219 | 219 | |
| 220 | - $points_types[ $slug ] = $settings['name']; |
|
| 220 | + $points_types[$slug] = $settings['name']; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( isset( $args['options'] ) && is_array( $args['options'] ) ) { |
|
| 223 | + if (isset($args['options']) && is_array($args['options'])) { |
|
| 224 | 224 | $points_types = $args['options'] + $points_types; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $dropdown = new WordPoints_Dropdown_Builder( $points_types, $args ); |
|
| 227 | + $dropdown = new WordPoints_Dropdown_Builder($points_types, $args); |
|
| 228 | 228 | |
| 229 | 229 | $dropdown->display(); |
| 230 | 230 | } |
@@ -238,27 +238,27 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param int $user_id The ID of the user just deleted. |
| 240 | 240 | */ |
| 241 | -function wordpoints_delete_points_logs_for_user( $user_id ) { |
|
| 241 | +function wordpoints_delete_points_logs_for_user($user_id) { |
|
| 242 | 242 | |
| 243 | 243 | global $wpdb; |
| 244 | 244 | |
| 245 | - $query_args = array( 'fields' => 'id', 'user_id' => $user_id ); |
|
| 245 | + $query_args = array('fields' => 'id', 'user_id' => $user_id); |
|
| 246 | 246 | |
| 247 | 247 | // If the user is being deleted from all blogs on multisite. |
| 248 | - if ( is_multisite() && ! get_userdata( $user_id ) ) { |
|
| 248 | + if (is_multisite() && ! get_userdata($user_id)) { |
|
| 249 | 249 | $query_args['blog_id'] = 0; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // Delete log meta. |
| 253 | - $query = new WordPoints_Points_Logs_Query( $query_args ); |
|
| 253 | + $query = new WordPoints_Points_Logs_Query($query_args); |
|
| 254 | 254 | |
| 255 | - foreach ( $query->get( 'col' ) as $log_id ) { |
|
| 256 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
| 255 | + foreach ($query->get('col') as $log_id) { |
|
| 256 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $where = array( 'user_id' => $user_id ); |
|
| 259 | + $where = array('user_id' => $user_id); |
|
| 260 | 260 | |
| 261 | - if ( ! isset( $query_args['blog_id'] ) ) { |
|
| 261 | + if ( ! isset($query_args['blog_id'])) { |
|
| 262 | 262 | $where['blog_id'] = $wpdb->blogid; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | ,'%d' |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | - wordpoints_flush_points_logs_caches( array( 'user_id' => $user_id ) ); |
|
| 272 | + wordpoints_flush_points_logs_caches(array('user_id' => $user_id)); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -281,21 +281,21 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @param int $blog_id The ID of the blog being deleted. |
| 283 | 283 | */ |
| 284 | -function wordpoints_delete_points_logs_for_blog( $blog_id ) { |
|
| 284 | +function wordpoints_delete_points_logs_for_blog($blog_id) { |
|
| 285 | 285 | |
| 286 | 286 | global $wpdb; |
| 287 | 287 | |
| 288 | 288 | // Delete log meta. |
| 289 | - $query = new WordPoints_Points_Logs_Query( array( 'fields' => 'id' ) ); |
|
| 289 | + $query = new WordPoints_Points_Logs_Query(array('fields' => 'id')); |
|
| 290 | 290 | |
| 291 | - foreach ( $query->get( 'col' ) as $log_id ) { |
|
| 292 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
| 291 | + foreach ($query->get('col') as $log_id) { |
|
| 292 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // Now delete the logs. |
| 296 | 296 | $wpdb->delete( |
| 297 | 297 | $wpdb->wordpoints_points_logs |
| 298 | - ,array( 'blog_id' => $blog_id ) |
|
| 298 | + ,array('blog_id' => $blog_id) |
|
| 299 | 299 | ,'%d' |
| 300 | 300 | ); |
| 301 | 301 | |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @param string $points_type The type of points the settings are being shown for. |
| 313 | 313 | */ |
| 314 | -function wordpoints_points_settings_custom_meta_key_message( $points_type ) { |
|
| 314 | +function wordpoints_points_settings_custom_meta_key_message($points_type) { |
|
| 315 | 315 | |
| 316 | - $custom_key = wordpoints_get_points_type_setting( $points_type, 'meta_key' ); |
|
| 316 | + $custom_key = wordpoints_get_points_type_setting($points_type, 'meta_key'); |
|
| 317 | 317 | |
| 318 | - if ( ! empty( $custom_key ) ) { |
|
| 319 | - echo '<p>' . esc_html( sprintf( __( 'This points type uses a custom meta key: %s', 'wordpoints' ), $custom_key ) ) . '</p>'; |
|
| 318 | + if ( ! empty($custom_key)) { |
|
| 319 | + echo '<p>' . esc_html(sprintf(__('This points type uses a custom meta key: %s', 'wordpoints'), $custom_key)) . '</p>'; |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
@@ -329,19 +329,19 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @param string $points_type The type of points whose logs are being displayed. |
| 331 | 331 | */ |
| 332 | -function wordpoints_points_logs_custom_meta_key_message( $points_type ) { |
|
| 332 | +function wordpoints_points_logs_custom_meta_key_message($points_type) { |
|
| 333 | 333 | |
| 334 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 334 | + if ( ! current_user_can('manage_options')) { |
|
| 335 | 335 | return; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - $custom_key = wordpoints_get_points_type_setting( $points_type, 'meta_key' ); |
|
| 338 | + $custom_key = wordpoints_get_points_type_setting($points_type, 'meta_key'); |
|
| 339 | 339 | |
| 340 | - if ( ! empty( $custom_key ) ) { |
|
| 340 | + if ( ! empty($custom_key)) { |
|
| 341 | 341 | wordpoints_show_admin_message( |
| 342 | 342 | esc_html( |
| 343 | 343 | sprintf( |
| 344 | - __( 'This points type uses a custom meta key (“%s”). If this key is also used by another plugin, changes made by it will not be logged. Only transactions performed by WordPoints are included in the logs.', 'wordpoints' ) |
|
| 344 | + __('This points type uses a custom meta key (“%s”). If this key is also used by another plugin, changes made by it will not be logged. Only transactions performed by WordPoints are included in the logs.', 'wordpoints') |
|
| 345 | 345 | , $custom_key |
| 346 | 346 | ) |
| 347 | 347 | ) |
@@ -360,18 +360,18 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function wordpoints_points_add_global_cache_groups() { |
| 362 | 362 | |
| 363 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
| 363 | + if (function_exists('wp_cache_add_global_groups')) { |
|
| 364 | 364 | |
| 365 | 365 | $groups = array( |
| 366 | 366 | 'wordpoints_network_points_logs_query', |
| 367 | 367 | 'wordpoints_points_log_meta', |
| 368 | 368 | ); |
| 369 | 369 | |
| 370 | - if ( is_wordpoints_network_active() ) { |
|
| 370 | + if (is_wordpoints_network_active()) { |
|
| 371 | 371 | $groups[] = 'wordpoints_points_top_users'; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - wp_cache_add_global_groups( $groups ); |
|
| 374 | + wp_cache_add_global_groups($groups); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | function wordpoints_register_points_widgets() { |
| 18 | 18 | |
| 19 | 19 | // My points widget. |
| 20 | - register_widget( 'WordPoints_My_Points_Widget' ); |
|
| 20 | + register_widget('WordPoints_My_Points_Widget'); |
|
| 21 | 21 | |
| 22 | 22 | // Top users widget. |
| 23 | - register_widget( 'WordPoints_Top_Users_Points_Widget' ); |
|
| 23 | + register_widget('WordPoints_Top_Users_Points_Widget'); |
|
| 24 | 24 | |
| 25 | 25 | // Points logs widget. |
| 26 | - register_widget( 'WordPoints_Points_Logs_Widget' ); |
|
| 26 | + register_widget('WordPoints_Points_Logs_Widget'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | /** |
| 39 | 39 | * @since 1.9.0 |
| 40 | 40 | */ |
| 41 | - protected function verify_settings( $instance ) { |
|
| 41 | + protected function verify_settings($instance) { |
|
| 42 | 42 | |
| 43 | - if ( isset( $this->defaults['points_type'] ) ) { |
|
| 43 | + if (isset($this->defaults['points_type'])) { |
|
| 44 | 44 | |
| 45 | 45 | if ( |
| 46 | - empty( $instance['points_type'] ) |
|
| 47 | - || ! wordpoints_is_points_type( $instance['points_type'] ) |
|
| 46 | + empty($instance['points_type']) |
|
| 47 | + || ! wordpoints_is_points_type($instance['points_type']) |
|
| 48 | 48 | ) { |
| 49 | 49 | return new WP_Error( |
| 50 | 50 | 'wordpoints_widget_invalid_points_type' |
| 51 | - , esc_html__( 'Please select a valid points type.', 'wordpoints' ) |
|
| 51 | + , esc_html__('Please select a valid points type.', 'wordpoints') |
|
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return parent::verify_settings( $instance ); |
|
| 56 | + return parent::verify_settings($instance); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param string $maybe_points_type The variable to insure is a points type. |
| 69 | 69 | */ |
| 70 | - protected function make_a_points_type( &$maybe_points_type ) { |
|
| 70 | + protected function make_a_points_type(&$maybe_points_type) { |
|
| 71 | 71 | |
| 72 | - if ( ! wordpoints_is_points_type( $maybe_points_type ) ) { |
|
| 72 | + if ( ! wordpoints_is_points_type($maybe_points_type)) { |
|
| 73 | 73 | |
| 74 | 74 | $maybe_points_type = wordpoints_get_default_points_type(); |
| 75 | 75 | |
| 76 | - if ( ! $maybe_points_type ) { |
|
| 76 | + if ( ! $maybe_points_type) { |
|
| 77 | 77 | |
| 78 | 78 | $points_types = wordpoints_get_points_types(); |
| 79 | 79 | |
| 80 | - $maybe_points_type = key( $points_types ); |
|
| 80 | + $maybe_points_type = key($points_types); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @since 2.0.0 |
| 87 | 87 | */ |
| 88 | - public function update( $new_instance, $old_instance ) { |
|
| 88 | + public function update($new_instance, $old_instance) { |
|
| 89 | 89 | |
| 90 | - parent::update( $new_instance, $old_instance ); |
|
| 90 | + parent::update($new_instance, $old_instance); |
|
| 91 | 91 | |
| 92 | - $this->make_a_points_type( $this->instance['points_type'] ); |
|
| 92 | + $this->make_a_points_type($this->instance['points_type']); |
|
| 93 | 93 | |
| 94 | 94 | return $this->instance; |
| 95 | 95 | } |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | /** |
| 98 | 98 | * @since 2.0.0 |
| 99 | 99 | */ |
| 100 | - public function form( $instance ) { |
|
| 100 | + public function form($instance) { |
|
| 101 | 101 | |
| 102 | - parent::form( $instance ); |
|
| 102 | + parent::form($instance); |
|
| 103 | 103 | |
| 104 | 104 | $this->form_points_type_field(); |
| 105 | 105 | |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $dropdown_args = array( |
| 117 | 117 | 'selected' => $this->instance['points_type'], |
| 118 | - 'id' => $this->get_field_id( 'points_type' ), |
|
| 119 | - 'name' => $this->get_field_name( 'points_type' ), |
|
| 118 | + 'id' => $this->get_field_id('points_type'), |
|
| 119 | + 'name' => $this->get_field_name('points_type'), |
|
| 120 | 120 | 'class' => 'widefat', |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | 123 | ?> |
| 124 | 124 | |
| 125 | 125 | <p> |
| 126 | - <label for="<?php echo esc_attr( $dropdown_args['id'] ); ?>"><?php echo esc_html_x( 'Points type', 'form label', 'wordpoints' ); ?></label> |
|
| 127 | - <?php wordpoints_points_types_dropdown( $dropdown_args ); ?> |
|
| 126 | + <label for="<?php echo esc_attr($dropdown_args['id']); ?>"><?php echo esc_html_x('Points type', 'form label', 'wordpoints'); ?></label> |
|
| 127 | + <?php wordpoints_points_types_dropdown($dropdown_args); ?> |
|
| 128 | 128 | </p> |
| 129 | 129 | |
| 130 | 130 | <?php |
@@ -152,45 +152,45 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | parent::__construct( |
| 154 | 154 | 'WordPoints_Points_Widget' |
| 155 | - , __( 'WordPoints', 'wordpoints' ) |
|
| 155 | + , __('WordPoints', 'wordpoints') |
|
| 156 | 156 | , array( |
| 157 | - 'description' => __( 'Display the points of the current logged in user.', 'wordpoints' ), |
|
| 157 | + 'description' => __('Display the points of the current logged in user.', 'wordpoints'), |
|
| 158 | 158 | 'wordpoints_hook_slug' => 'points', |
| 159 | 159 | ) |
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | $this->defaults = array( |
| 163 | - 'title' => _x( 'My Points', 'widget title', 'wordpoints' ), |
|
| 163 | + 'title' => _x('My Points', 'widget title', 'wordpoints'), |
|
| 164 | 164 | 'points_type' => wordpoints_get_default_points_type(), |
| 165 | - 'text' => sprintf( __( 'Points: %s', 'wordpoints' ), '%points%' ), |
|
| 166 | - 'alt_text' => __( 'You must be logged in to view your points.', 'wordpoints' ), |
|
| 165 | + 'text' => sprintf(__('Points: %s', 'wordpoints'), '%points%'), |
|
| 166 | + 'alt_text' => __('You must be logged in to view your points.', 'wordpoints'), |
|
| 167 | 167 | 'number_logs' => 5, |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - add_filter( 'wordpoints_points_widget_text', 'esc_html', 20 ); |
|
| 170 | + add_filter('wordpoints_points_widget_text', 'esc_html', 20); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * @since 1.9.0 |
| 175 | 175 | */ |
| 176 | - protected function verify_settings( $instance ) { |
|
| 176 | + protected function verify_settings($instance) { |
|
| 177 | 177 | |
| 178 | - if ( ! is_user_logged_in() && empty( $instance['alt_text'] ) ) { |
|
| 178 | + if ( ! is_user_logged_in() && empty($instance['alt_text'])) { |
|
| 179 | 179 | return new WP_Error; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | if ( |
| 183 | - ! isset( $instance['number_logs'] ) |
|
| 184 | - || ! wordpoints_posint( $instance['number_logs'] ) |
|
| 183 | + ! isset($instance['number_logs']) |
|
| 184 | + || ! wordpoints_posint($instance['number_logs']) |
|
| 185 | 185 | ) { |
| 186 | 186 | $instance['number_logs'] = 0; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // In case the points type isn't set, we do this first. |
| 190 | - $instance = parent::verify_settings( $instance ); |
|
| 190 | + $instance = parent::verify_settings($instance); |
|
| 191 | 191 | |
| 192 | - if ( ! is_wp_error( $instance ) && is_user_logged_in() && empty( $instance['text'] ) ) { |
|
| 193 | - $instance['text'] = wordpoints_get_points_type_setting( $instance['points_type'], 'name' ) . ': %points%'; |
|
| 192 | + if ( ! is_wp_error($instance) && is_user_logged_in() && empty($instance['text'])) { |
|
| 193 | + $instance['text'] = wordpoints_get_points_type_setting($instance['points_type'], 'name') . ': %points%'; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | return $instance; |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | /** |
| 200 | 200 | * @since 1.9.0 |
| 201 | 201 | */ |
| 202 | - protected function widget_body( $instance ) { |
|
| 202 | + protected function widget_body($instance) { |
|
| 203 | 203 | |
| 204 | - if ( is_user_logged_in() ) { |
|
| 204 | + if (is_user_logged_in()) { |
|
| 205 | 205 | |
| 206 | 206 | $text = str_replace( |
| 207 | 207 | '%points%', |
| 208 | 208 | wordpoints_format_points( |
| 209 | - wordpoints_get_points( get_current_user_id(), $instance['points_type'] ), |
|
| 209 | + wordpoints_get_points(get_current_user_id(), $instance['points_type']), |
|
| 210 | 210 | $instance['points_type'], |
| 211 | 211 | 'my_points_widget' |
| 212 | 212 | ), |
@@ -232,20 +232,20 @@ discard block |
||
| 232 | 232 | * @param string $text The text for the widget set by the user. |
| 233 | 233 | * @param array $instance The settings for this instance of the widget. |
| 234 | 234 | */ |
| 235 | - $text = apply_filters( 'wordpoints_points_widget_text', $text, $instance ); |
|
| 235 | + $text = apply_filters('wordpoints_points_widget_text', $text, $instance); |
|
| 236 | 236 | |
| 237 | 237 | echo '<div class="wordpoints-points-widget-text">', $text, '</div><br />'; // XSS OK, WPCS |
| 238 | 238 | |
| 239 | - if ( is_user_logged_in() && 0 !== $instance['number_logs'] ) { |
|
| 239 | + if (is_user_logged_in() && 0 !== $instance['number_logs']) { |
|
| 240 | 240 | |
| 241 | - $query_args = wordpoints_get_points_logs_query_args( $instance['points_type'], 'current_user' ); |
|
| 241 | + $query_args = wordpoints_get_points_logs_query_args($instance['points_type'], 'current_user'); |
|
| 242 | 242 | |
| 243 | 243 | $query_args['limit'] = $instance['number_logs']; |
| 244 | 244 | |
| 245 | - $logs_query = new WordPoints_Points_Logs_Query( $query_args ); |
|
| 246 | - $logs_query->prime_cache( 'current_user:%points_type%:%user_id%' ); |
|
| 245 | + $logs_query = new WordPoints_Points_Logs_Query($query_args); |
|
| 246 | + $logs_query->prime_cache('current_user:%points_type%:%user_id%'); |
|
| 247 | 247 | |
| 248 | - wordpoints_show_points_logs( $logs_query, array( 'paginate' => false, 'searchable' => false, 'show_users' => false ) ); |
|
| 248 | + wordpoints_show_points_logs($logs_query, array('paginate' => false, 'searchable' => false, 'show_users' => false)); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -259,14 +259,14 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @return array The updated settings for the widget instance. |
| 261 | 261 | */ |
| 262 | - public function update( $new_instance, $old_instance ) { |
|
| 262 | + public function update($new_instance, $old_instance) { |
|
| 263 | 263 | |
| 264 | - parent::update( $new_instance, $old_instance ); |
|
| 264 | + parent::update($new_instance, $old_instance); |
|
| 265 | 265 | |
| 266 | - $this->instance['text'] = trim( $this->instance['text'] ); |
|
| 267 | - $this->instance['alt_text'] = trim( $this->instance['alt_text'] ); |
|
| 266 | + $this->instance['text'] = trim($this->instance['text']); |
|
| 267 | + $this->instance['alt_text'] = trim($this->instance['alt_text']); |
|
| 268 | 268 | |
| 269 | - if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) { |
|
| 269 | + if ( ! wordpoints_posint($this->instance['number_logs'])) { |
|
| 270 | 270 | $this->instance['number_logs'] = 0; |
| 271 | 271 | } |
| 272 | 272 | |
@@ -276,16 +276,16 @@ discard block |
||
| 276 | 276 | /** |
| 277 | 277 | * @since 1.0.0 |
| 278 | 278 | */ |
| 279 | - public function form( $instance ) { |
|
| 279 | + public function form($instance) { |
|
| 280 | 280 | |
| 281 | - parent::form( $instance ); |
|
| 281 | + parent::form($instance); |
|
| 282 | 282 | |
| 283 | 283 | ?> |
| 284 | 284 | |
| 285 | 285 | <p> |
| 286 | - <label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Widget text', 'wordpoints' ); ?></label> |
|
| 287 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" value="<?php echo esc_attr( $this->instance['text'] ); ?>" /> |
|
| 288 | - <small><i><?php echo esc_html( sprintf( __( '%s will be replaced with the points of the logged in user', 'wordpoints' ), '%points%' ) ); ?></i></small> |
|
| 286 | + <label for="<?php echo esc_attr($this->get_field_id('text')); ?>"><?php esc_html_e('Widget text', 'wordpoints'); ?></label> |
|
| 287 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('text')); ?>" name="<?php echo esc_attr($this->get_field_name('text')); ?>" value="<?php echo esc_attr($this->instance['text']); ?>" /> |
|
| 288 | + <small><i><?php echo esc_html(sprintf(__('%s will be replaced with the points of the logged in user', 'wordpoints'), '%points%')); ?></i></small> |
|
| 289 | 289 | <?php |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -295,19 +295,19 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @param array $instance The settings of the current widget instance. |
| 297 | 297 | */ |
| 298 | - do_action( 'wordpoints_my_points_widget_below_text_field', $this->instance ); |
|
| 298 | + do_action('wordpoints_my_points_widget_below_text_field', $this->instance); |
|
| 299 | 299 | |
| 300 | 300 | ?> |
| 301 | 301 | </p> |
| 302 | 302 | <p> |
| 303 | - <label for="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>"><?php esc_html_e( 'Text if the user is not logged in', 'wordpoints' ); ?></label> |
|
| 304 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'alt_text' ) ); ?>" value="<?php echo esc_attr( $this->instance['alt_text'] ); ?>" /> |
|
| 305 | - <small><i><?php esc_html_e( 'Leave this field blank to hide the widget if the user is not logged in', 'wordpoints' ); ?></i></small> |
|
| 303 | + <label for="<?php echo esc_attr($this->get_field_id('alt_text')); ?>"><?php esc_html_e('Text if the user is not logged in', 'wordpoints'); ?></label> |
|
| 304 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('alt_text')); ?>" name="<?php echo esc_attr($this->get_field_name('alt_text')); ?>" value="<?php echo esc_attr($this->instance['alt_text']); ?>" /> |
|
| 305 | + <small><i><?php esc_html_e('Leave this field blank to hide the widget if the user is not logged in', 'wordpoints'); ?></i></small> |
|
| 306 | 306 | </p> |
| 307 | 307 | <p> |
| 308 | - <label for="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>"><?php esc_html_e( 'Number of latest log entries for this user to display', 'wordpoints' ); ?></label> |
|
| 309 | - <input type="number" min="0" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_logs' ) ); ?>" value="<?php echo esc_attr( $this->instance['number_logs'] ); ?>" /> |
|
| 310 | - <small><i><?php esc_html_e( 'Set this to 0 to keep from showing any logs', 'wordpoints' ); ?></i></small> |
|
| 308 | + <label for="<?php echo esc_attr($this->get_field_id('number_logs')); ?>"><?php esc_html_e('Number of latest log entries for this user to display', 'wordpoints'); ?></label> |
|
| 309 | + <input type="number" min="0" class="widefat" id="<?php echo esc_attr($this->get_field_id('number_logs')); ?>" name="<?php echo esc_attr($this->get_field_name('number_logs')); ?>" value="<?php echo esc_attr($this->instance['number_logs']); ?>" /> |
|
| 310 | + <small><i><?php esc_html_e('Set this to 0 to keep from showing any logs', 'wordpoints'); ?></i></small> |
|
| 311 | 311 | </p> |
| 312 | 312 | |
| 313 | 313 | <?php |
@@ -338,15 +338,15 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | parent::__construct( |
| 340 | 340 | 'WordPoints_Top_Users_Widget' |
| 341 | - , _x( 'WordPoints Top Users', 'widget name', 'wordpoints' ) |
|
| 341 | + , _x('WordPoints Top Users', 'widget name', 'wordpoints') |
|
| 342 | 342 | , array( |
| 343 | - 'description' => __( 'Showcase the users with the most points.', 'wordpoints' ), |
|
| 343 | + 'description' => __('Showcase the users with the most points.', 'wordpoints'), |
|
| 344 | 344 | 'wordpoints_hook_slug' => 'top_users', |
| 345 | 345 | ) |
| 346 | 346 | ); |
| 347 | 347 | |
| 348 | 348 | $this->defaults = array( |
| 349 | - 'title' => _x( 'Top Users', 'widget title', 'wordpoints' ), |
|
| 349 | + 'title' => _x('Top Users', 'widget title', 'wordpoints'), |
|
| 350 | 350 | 'points_type' => wordpoints_get_default_points_type(), |
| 351 | 351 | 'num_users' => 3, |
| 352 | 352 | ); |
@@ -355,19 +355,19 @@ discard block |
||
| 355 | 355 | /** |
| 356 | 356 | * @since 1.9.0 |
| 357 | 357 | */ |
| 358 | - protected function verify_settings( $instance ) { |
|
| 358 | + protected function verify_settings($instance) { |
|
| 359 | 359 | |
| 360 | - if ( empty( $instance['num_users'] ) ) { |
|
| 360 | + if (empty($instance['num_users'])) { |
|
| 361 | 361 | $instance['num_users'] = $this->defaults['num_users']; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - return parent::verify_settings( $instance ); |
|
| 364 | + return parent::verify_settings($instance); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * @since 1.9.0 |
| 369 | 369 | */ |
| 370 | - protected function widget_body( $instance ) { |
|
| 370 | + protected function widget_body($instance) { |
|
| 371 | 371 | |
| 372 | 372 | wordpoints_points_show_top_users( |
| 373 | 373 | $instance['num_users'] |
@@ -386,11 +386,11 @@ discard block |
||
| 386 | 386 | * |
| 387 | 387 | * @return array The updated settings for the widget instance. |
| 388 | 388 | */ |
| 389 | - public function update( $new_instance, $old_instance ) { |
|
| 389 | + public function update($new_instance, $old_instance) { |
|
| 390 | 390 | |
| 391 | - parent::update( $new_instance, $old_instance ); |
|
| 391 | + parent::update($new_instance, $old_instance); |
|
| 392 | 392 | |
| 393 | - if ( ! wordpoints_posint( $this->instance['num_users'] ) ) { |
|
| 393 | + if ( ! wordpoints_posint($this->instance['num_users'])) { |
|
| 394 | 394 | $this->instance['num_users'] = $this->defaults['num_users']; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -400,19 +400,19 @@ discard block |
||
| 400 | 400 | /** |
| 401 | 401 | * @since 1.0.0 |
| 402 | 402 | */ |
| 403 | - public function form( $instance ) { |
|
| 403 | + public function form($instance) { |
|
| 404 | 404 | |
| 405 | - parent::form( $instance ); |
|
| 405 | + parent::form($instance); |
|
| 406 | 406 | |
| 407 | - if ( ! wordpoints_posint( $this->instance['num_users'] ) ) { |
|
| 407 | + if ( ! wordpoints_posint($this->instance['num_users'])) { |
|
| 408 | 408 | $this->instance['num_users'] = $this->defaults['num_users']; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | ?> |
| 412 | 412 | |
| 413 | 413 | <p> |
| 414 | - <label for="<?php echo esc_attr( $this->get_field_id( 'num_users' ) ); ?>"><?php esc_html_e( 'Number of top users to show', 'wordpoints' ); ?></label> |
|
| 415 | - <input type="number" min="1" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'num_users' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'num_users' ) ); ?>" value="<?php echo absint( $this->instance['num_users'] ); ?>" /> |
|
| 414 | + <label for="<?php echo esc_attr($this->get_field_id('num_users')); ?>"><?php esc_html_e('Number of top users to show', 'wordpoints'); ?></label> |
|
| 415 | + <input type="number" min="1" class="widefat" id="<?php echo esc_attr($this->get_field_id('num_users')); ?>" name="<?php echo esc_attr($this->get_field_name('num_users')); ?>" value="<?php echo absint($this->instance['num_users']); ?>" /> |
|
| 416 | 416 | </p> |
| 417 | 417 | |
| 418 | 418 | <?php |
@@ -437,15 +437,15 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | parent::__construct( |
| 439 | 439 | 'WordPoints_Points_Logs_Widget' |
| 440 | - , _x( 'Points Logs', 'widget name', 'wordpoints' ) |
|
| 440 | + , _x('Points Logs', 'widget name', 'wordpoints') |
|
| 441 | 441 | , array( |
| 442 | - 'description' => __( 'Display the latest points activity.', 'wordpoints' ), |
|
| 442 | + 'description' => __('Display the latest points activity.', 'wordpoints'), |
|
| 443 | 443 | 'wordpoints_hook_slug' => 'points_logs', |
| 444 | 444 | ) |
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | 447 | $this->defaults = array( |
| 448 | - 'title' => _x( 'Points Logs', 'widget title', 'wordpoints' ), |
|
| 448 | + 'title' => _x('Points Logs', 'widget title', 'wordpoints'), |
|
| 449 | 449 | 'number_logs' => 10, |
| 450 | 450 | 'points_type' => wordpoints_get_default_points_type(), |
| 451 | 451 | ); |
@@ -454,28 +454,28 @@ discard block |
||
| 454 | 454 | /** |
| 455 | 455 | * @since 1.9.0 |
| 456 | 456 | */ |
| 457 | - protected function verify_settings( $instance ) { |
|
| 457 | + protected function verify_settings($instance) { |
|
| 458 | 458 | |
| 459 | - if ( ! wordpoints_posint( $instance['number_logs'] ) ) { |
|
| 459 | + if ( ! wordpoints_posint($instance['number_logs'])) { |
|
| 460 | 460 | $instance['number_logs'] = $this->defaults['number_logs']; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - return parent::verify_settings( $instance ); |
|
| 463 | + return parent::verify_settings($instance); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
| 467 | 467 | * @since 1.9.0 |
| 468 | 468 | */ |
| 469 | - public function widget_body( $instance ) { |
|
| 469 | + public function widget_body($instance) { |
|
| 470 | 470 | |
| 471 | - $query_args = wordpoints_get_points_logs_query_args( $instance['points_type'] ); |
|
| 471 | + $query_args = wordpoints_get_points_logs_query_args($instance['points_type']); |
|
| 472 | 472 | |
| 473 | 473 | $query_args['limit'] = $instance['number_logs']; |
| 474 | 474 | |
| 475 | - $logs_query = new WordPoints_Points_Logs_Query( $query_args ); |
|
| 475 | + $logs_query = new WordPoints_Points_Logs_Query($query_args); |
|
| 476 | 476 | $logs_query->prime_cache(); |
| 477 | 477 | |
| 478 | - wordpoints_show_points_logs( $logs_query, array( 'paginate' => false, 'searchable' => false ) ); |
|
| 478 | + wordpoints_show_points_logs($logs_query, array('paginate' => false, 'searchable' => false)); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | * |
| 489 | 489 | * @return array The updated settings for the widget instance. |
| 490 | 490 | */ |
| 491 | - public function update( $new_instance, $old_instance ) { |
|
| 491 | + public function update($new_instance, $old_instance) { |
|
| 492 | 492 | |
| 493 | - parent::update( $new_instance, $old_instance ); |
|
| 493 | + parent::update($new_instance, $old_instance); |
|
| 494 | 494 | |
| 495 | - if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) { |
|
| 495 | + if ( ! wordpoints_posint($this->instance['number_logs'])) { |
|
| 496 | 496 | $this->instance['number_logs'] = $this->defaults['number_logs']; |
| 497 | 497 | } |
| 498 | 498 | |
@@ -502,19 +502,19 @@ discard block |
||
| 502 | 502 | /** |
| 503 | 503 | * @since 1.0.0 |
| 504 | 504 | */ |
| 505 | - public function form( $instance ) { |
|
| 505 | + public function form($instance) { |
|
| 506 | 506 | |
| 507 | - parent::form( $instance ); |
|
| 507 | + parent::form($instance); |
|
| 508 | 508 | |
| 509 | - if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) { |
|
| 509 | + if ( ! wordpoints_posint($this->instance['number_logs'])) { |
|
| 510 | 510 | $this->instance['number_logs'] = $this->defaults['number_logs']; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | ?> |
| 514 | 514 | |
| 515 | 515 | <p> |
| 516 | - <label for="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>"><?php esc_html_e( 'Number of log entries to display', 'wordpoints' ); ?></label> |
|
| 517 | - <input type="number" min="1" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_logs' ) ); ?>" value="<?php echo absint( $this->instance['number_logs'] ); ?>" /> |
|
| 516 | + <label for="<?php echo esc_attr($this->get_field_id('number_logs')); ?>"><?php esc_html_e('Number of log entries to display', 'wordpoints'); ?></label> |
|
| 517 | + <input type="number" min="1" class="widefat" id="<?php echo esc_attr($this->get_field_id('number_logs')); ?>" name="<?php echo esc_attr($this->get_field_name('number_logs')); ?>" value="<?php echo absint($this->instance['number_logs']); ?>" /> |
|
| 518 | 518 | </p> |
| 519 | 519 | |
| 520 | 520 | <?php |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param WordPoints_App $components The components app. |
| 18 | 18 | */ |
| 19 | -function wordpoints_points_components_app_init( $components ) { |
|
| 19 | +function wordpoints_points_components_app_init($components) { |
|
| 20 | 20 | |
| 21 | 21 | $apps = $components->sub_apps(); |
| 22 | 22 | |
| 23 | - $apps->register( 'points', 'WordPoints_App' ); |
|
| 23 | + $apps->register('points', 'WordPoints_App'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param WordPoints_App $app The points app. |
| 34 | 34 | */ |
| 35 | -function wordpoints_points_apps_init( $app ) { |
|
| 35 | +function wordpoints_points_apps_init($app) { |
|
| 36 | 36 | |
| 37 | 37 | $apps = $app->sub_apps(); |
| 38 | 38 | |
| 39 | - $apps->register( 'logs', 'WordPoints_App' ); |
|
| 39 | + $apps->register('logs', 'WordPoints_App'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @param WordPoints_App $app The points logs app. |
| 50 | 50 | */ |
| 51 | -function wordpoints_points_logs_apps_init( $app ) { |
|
| 51 | +function wordpoints_points_logs_apps_init($app) { |
|
| 52 | 52 | |
| 53 | 53 | $apps = $app->sub_apps(); |
| 54 | 54 | |
| 55 | - $apps->register( 'views', 'WordPoints_Class_Registry' ); |
|
| 56 | - $apps->register( 'viewing_restrictions', 'WordPoints_Points_Logs_Viewing_Restrictions' ); |
|
| 55 | + $apps->register('views', 'WordPoints_Class_Registry'); |
|
| 56 | + $apps->register('viewing_restrictions', 'WordPoints_Points_Logs_Viewing_Restrictions'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param WordPoints_Class_RegistryI $views The points log views registry. |
| 67 | 67 | */ |
| 68 | -function wordpoints_points_logs_views_init( $views ) { |
|
| 68 | +function wordpoints_points_logs_views_init($views) { |
|
| 69 | 69 | |
| 70 | - $views->register( 'table', 'WordPoints_Points_Logs_View_Table' ); |
|
| 70 | + $views->register('table', 'WordPoints_Points_Logs_View_Table'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param WordPoints_Points_Logs_Viewing_Restrictions $restrictions The registry. |
| 81 | 81 | */ |
| 82 | -function wordpoints_points_logs_viewing_restrictions_init( $restrictions ) { |
|
| 82 | +function wordpoints_points_logs_viewing_restrictions_init($restrictions) { |
|
| 83 | 83 | |
| 84 | - $restrictions->register( 'all', 'hooks', 'WordPoints_Points_Logs_Viewing_Restriction_Hooks' ); |
|
| 84 | + $restrictions->register('all', 'hooks', 'WordPoints_Points_Logs_Viewing_Restriction_Hooks'); |
|
| 85 | 85 | |
| 86 | - $restrictions->register( 'comment_approve', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post' ); |
|
| 87 | - $restrictions->register( 'comment_received', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post' ); |
|
| 88 | - $restrictions->register( 'post_publish', 'read_post', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Post' ); |
|
| 86 | + $restrictions->register('comment_approve', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post'); |
|
| 87 | + $restrictions->register('comment_received', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post'); |
|
| 88 | + $restrictions->register('post_publish', 'read_post', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Post'); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // EOF |