← All changes
|
includes/users/class-charitable-user-avatar.php
+23
-94
1.7.0.11
→
1.8.13
View file →
| @@ -6,12 +6,13 @@ | ||
| 6 | 6 | * |
| 7 | 7 | * @package Charitable User Avatar |
| 8 | 8 | * @copyright Copyright (c) 2017, Eric Daams |
| 9 | 9 | * @license http://opensource.org/licenses/gpl-1.0.0.php GNU Public License |
| 10 | - * @since 1.0.0 | |
| 10 | + * @since 1.0.0 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { exit; } | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; } | |
| 14 | 15 | |
| 15 | 16 | if ( ! class_exists( 'Charitable_User_Avatar' ) ) : |
| 16 | 17 | |
| 17 | 18 | /** |
| @@ -30,9 +31,9 @@ | ||
| 30 | 31 | /* @var string */ |
| 31 | 32 | const NAME = 'Charitable User Avatar'; |
| 32 | 33 | |
| 33 | 34 | /* @var string */ |
| 34 | - const AUTHOR = 'Studio 164a'; | |
| 35 | + const AUTHOR = 'WPCharitable'; | |
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | 38 | * Single class instance. |
| 38 | 39 | * |
| @@ -71,16 +72,10 @@ | ||
| 71 | 72 | /** |
| 72 | 73 | * Create class instance. |
| 73 | 74 | * |
| 74 | 75 | * @since 1.0.0 |
| 75 | - * | |
| 76 | - * @param string $plugin_file The core plugin file. | |
| 77 | 76 | */ |
| 78 | 77 | public function __construct() { |
| 79 | - // $this->plugin_file = $plugin_file; | |
| 80 | - // $this->directory_path = plugin_dir_path( $plugin_file ); | |
| 81 | - // $this->directory_url = plugin_dir_url( $plugin_file ); | |
| 82 | - | |
| 83 | 78 | add_action( 'charitable_start', array( $this, 'start' ), 5 ); |
| 84 | 79 | } |
| 85 | 80 | |
| 86 | 81 | /** |
| @@ -111,34 +106,15 @@ | ||
| 111 | 106 | |
| 112 | 107 | // Set static instance. |
| 113 | 108 | self::$instance = $this; |
| 114 | 109 | |
| 115 | - // $this->load_dependencies(); | |
| 116 | - | |
| 117 | 110 | $this->attach_hooks_and_filters(); |
| 118 | 111 | |
| 119 | - // $this->maybe_start_ambassadors(); | |
| 120 | - | |
| 121 | - // $this->setup_licensing(); | |
| 122 | - | |
| 123 | - // $this->setup_i18n(); | |
| 124 | - | |
| 125 | - // Hook in here to do something when the plugin is first loaded. | |
| 112 | + // Hook in here to do something when the first loaded. | |
| 126 | 113 | do_action( 'charitable_user_avatar_start', $this ); |
| 127 | 114 | } |
| 128 | 115 | |
| 129 | 116 | /** |
| 130 | - * Include necessary files. | |
| 131 | - * | |
| 132 | - * @return void | |
| 133 | - * @since 1.0.0 | |
| 134 | - */ | |
| 135 | - private function load_dependencies() { | |
| 136 | - require_once( $this->get_path( 'includes' ) . 'charitable-user-avatar-functions.php' ); | |
| 137 | - require_once( $this->get_path( 'includes' ) . 'class-charitable-user-avatar-profile-form.php' ); | |
| 138 | - } | |
| 139 | - | |
| 140 | - /** | |
| 141 | 117 | * Set up hook and filter callback functions. |
| 142 | 118 | * |
| 143 | 119 | * @return void |
| 144 | 120 | * @since 1.0.0 |
| @@ -143,60 +119,13 @@ | ||
| 143 | 119 | * @return void |
| 144 | 120 | * @since 1.0.0 |
| 145 | 121 | */ |
| 146 | 122 | private function attach_hooks_and_filters() { |
| 147 | - // add_action( 'charitable_user_avatar_start', array( 'Charitable_User_Avatar_Profile_Form', 'start' ) ); | |
| 148 | - add_filter( 'charitable_user_avatar', array( $this, 'get_user_avatar' ), 10, 3 ); | |
| 149 | - add_filter( 'charitable_user_avatar_src', array( $this, 'get_user_avatar_src' ), 10, 3 ); | |
| 123 | + add_filter( 'charitable_user_avatar', array( $this, 'get_user_avatar' ), 10, 3 ); | |
| 124 | + add_filter( 'charitable_user_avatar_src', array( $this, 'get_user_avatar_src' ), 10, 3 ); | |
| 150 | 125 | } |
| 151 | 126 | |
| 152 | 127 | /** |
| 153 | - * Load up the Ambassadors integration if Ambassadors is installed. | |
| 154 | - * | |
| 155 | - * @return void | |
| 156 | - * @since 1.0.2 | |
| 157 | - */ | |
| 158 | - private function maybe_start_ambassadors() { | |
| 159 | - if ( ! class_exists( 'Charitable_Ambassadors' ) ) { | |
| 160 | - return; | |
| 161 | - } | |
| 162 | - | |
| 163 | - require_once( $this->get_path( 'includes' ) . 'ambassadors/class-charitable-user-avatar-campaign-form.php' ); | |
| 164 | - | |
| 165 | - add_action( 'charitable_user_avatar_start', array( 'Charitable_User_Avatar_Campaign_Form', 'start' ) ); | |
| 166 | - } | |
| 167 | - | |
| 168 | - /** | |
| 169 | - * Set up licensing for the extension. | |
| 170 | - * | |
| 171 | - * @return void | |
| 172 | - * @since 1.0.0 | |
| 173 | - */ | |
| 174 | - private function setup_licensing() { | |
| 175 | - charitable_get_helper( 'licenses' )->register_licensed_product( | |
| 176 | - Charitable_User_Avatar::NAME, | |
| 177 | - Charitable_User_Avatar::AUTHOR, | |
| 178 | - Charitable_User_Avatar::VERSION, | |
| 179 | - $this->plugin_file | |
| 180 | - ); | |
| 181 | - } | |
| 182 | - | |
| 183 | - /** | |
| 184 | - * Set up the internationalisation for the plugin. | |
| 185 | - * | |
| 186 | - * @return void | |
| 187 | - * @since 1.1.0 | |
| 188 | - */ | |
| 189 | - private function setup_i18n() { | |
| 190 | - if ( class_exists( 'Charitable_i18n' ) ) { | |
| 191 | - | |
| 192 | - require_once( $this->get_path( 'includes' ) . 'i18n/class-charitable-user-avatar-i18n.php' ); | |
| 193 | - | |
| 194 | - Charitable_User_Avatar_i18n::get_instance(); | |
| 195 | - } | |
| 196 | - } | |
| 197 | - | |
| 198 | - /** | |
| 199 | 128 | * Returns whether we are currently in the start phase of the plugin. |
| 200 | 129 | * |
| 201 | 130 | * @return bool |
| 202 | 131 | * @since 1.0.0 |
| @@ -227,38 +156,38 @@ | ||
| 227 | 156 | |
| 228 | 157 | /** |
| 229 | 158 | * Returns plugin paths. |
| 230 | 159 | * |
| 231 | - * @param string $path // If empty, returns the path to the plugin. | |
| 232 | - * @param bool $absolute_path // If true, returns the file system path. If false, returns it as a URL. | |
| 160 | + * @param string $type If empty, returns the path to the plugin. | |
| 161 | + * @param bool $absolute_path If true, returns the file system path. If false, returns it as a URL. | |
| 233 | 162 | * @return string |
| 234 | 163 | * @since 1.0.0 |
| 235 | 164 | */ |
| 236 | - public function get_path($type = '', $absolute_path = true ) { | |
| 165 | + public function get_path( $type = '', $absolute_path = true ) { | |
| 237 | 166 | $base = $absolute_path ? $this->directory_path : $this->directory_url; |
| 238 | 167 | |
| 239 | - switch( $type ) { | |
| 240 | - case 'includes' : | |
| 168 | + switch ( $type ) { | |
| 169 | + case 'includes': | |
| 241 | 170 | $path = $base . 'includes/'; |
| 242 | 171 | break; |
| 243 | 172 | |
| 244 | - case 'admin' : | |
| 173 | + case 'admin': | |
| 245 | 174 | $path = $base . 'includes/admin/'; |
| 246 | 175 | break; |
| 247 | 176 | |
| 248 | - case 'templates' : | |
| 177 | + case 'templates': | |
| 249 | 178 | $path = $base . 'templates/'; |
| 250 | 179 | break; |
| 251 | 180 | |
| 252 | - case 'assets' : | |
| 181 | + case 'assets': | |
| 253 | 182 | $path = $base . 'assets/'; |
| 254 | 183 | break; |
| 255 | 184 | |
| 256 | - case 'directory' : | |
| 185 | + case 'directory': | |
| 257 | 186 | $path = $base; |
| 258 | 187 | break; |
| 259 | 188 | |
| 260 | - default : | |
| 189 | + default: | |
| 261 | 190 | $path = $this->plugin_file; |
| 262 | 191 | } |
| 263 | 192 | |
| 264 | 193 | return $path; |
| @@ -268,9 +197,9 @@ | ||
| 268 | 197 | * Stores an object in the plugin's registry. |
| 269 | 198 | * |
| 270 | 199 | * @since 1.0.0 |
| 271 | 200 | * |
| 272 | - * @param mixed $object | |
| 201 | + * @param mixed $object The object to store. | |
| 273 | 202 | * @return void |
| 274 | 203 | */ |
| 275 | 204 | public function register_object( $object ) { |
| 276 | 205 | if ( ! is_object( $object ) ) { |
| @@ -319,11 +248,11 @@ | ||
| 319 | 248 | |
| 320 | 249 | /** |
| 321 | 250 | * Return the src of the user's avatar, or false if they have not uploaded their own. |
| 322 | 251 | * |
| 323 | - * @param string|false $avatar_src | |
| 252 | + * @param string|false $avatar_src | |
| 324 | 253 | * @param Charitable_User $user |
| 325 | - * @param string $size | |
| 254 | + * @param string $size | |
| 326 | 255 | * @return string|false |
| 327 | 256 | * @since 1.0.0 |
| 328 | 257 | */ |
| 329 | 258 | public function get_user_avatar_src( $avatar_src, Charitable_User $user, $size = '' ) { |
| @@ -332,9 +261,9 @@ | ||
| 332 | 261 | if ( $avatar_attachment_id ) { |
| 333 | 262 | $attachment_src = wp_get_attachment_image_src( $avatar_attachment_id, $size ); |
| 334 | 263 | |
| 335 | 264 | if ( $attachment_src ) { |
| 336 | - $avatar_src = $attachment_src[ 0 ]; | |
| 265 | + $avatar_src = $attachment_src[0]; | |
| 337 | 266 | } |
| 338 | 267 | } |
| 339 | 268 | |
| 340 | 269 | return $avatar_src; |
| @@ -350,9 +279,9 @@ | ||
| 350 | 279 | */ |
| 351 | 280 | public function __clone() { |
| 352 | 281 | charitable_get_deprecated()->doing_it_wrong( |
| 353 | 282 | __FUNCTION__, |
| 354 | - __( 'Cheatin’ huh?', 'charitable-user-avatar' ), | |
| 283 | + __( 'Cheatin’ huh?', 'charitable' ), | |
| 355 | 284 | '1.0.0' |
| 356 | 285 | ); |
| 357 | 286 | } |
| 358 | 287 | |
| @@ -364,9 +293,9 @@ | ||
| 364 | 293 | */ |
| 365 | 294 | public function __wakeup() { |
| 366 | 295 | charitable_get_deprecated()->doing_it_wrong( |
| 367 | 296 | __FUNCTION__, |
| 368 | - __( 'Cheatin’ huh?', 'charitable-user-avatar' ), | |
| 297 | + __( 'Cheatin’ huh?', 'charitable' ), | |
| 369 | 298 | '1.0.0' |
| 370 | 299 | ); |
| 371 | 300 | } |
| 372 | 301 | } |