@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | // If there's an overriding CSS file in the current template folder, use it. |
| 33 | 33 | $template_css_path = trailingslashit( get_stylesheet_directory() ) . 'gravityview/css/' . $css_file; |
| 34 | 34 | |
| 35 | - if( file_exists( $template_css_path ) ) { |
|
| 35 | + if ( file_exists( $template_css_path ) ) { |
|
| 36 | 36 | $path = trailingslashit( get_stylesheet_directory_uri() ) . 'gravityview/css/' . $css_file; |
| 37 | 37 | gravityview()->log->debug( 'Stylesheet override ({css_file})', array( 'css_file' => esc_attr( $css_file ) ) ); |
| 38 | 38 | } else { |
| 39 | 39 | // Default: use GravityView CSS file |
| 40 | 40 | |
| 41 | 41 | // If no path is provided, assume default plugin templates CSS folder |
| 42 | - if( '' === $dir_path ) { |
|
| 42 | + if ( '' === $dir_path ) { |
|
| 43 | 43 | $dir_path = GRAVITYVIEW_DIR . 'templates/css/'; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // plugins_url() expects a path to a file, not directory. We append a file to be stripped. |
| 47 | - $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
| 47 | + $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $path; |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $parsed_permalink = parse_url( get_permalink( $id ) ); |
| 84 | 84 | |
| 85 | - $permalink_args = isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false; |
|
| 85 | + $permalink_args = isset( $parsed_permalink[ 'query' ] ) ? $parsed_permalink[ 'query' ] : false; |
|
| 86 | 86 | |
| 87 | - if( empty( $permalink_args ) ) { |
|
| 87 | + if ( empty( $permalink_args ) ) { |
|
| 88 | 88 | return array(); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { |
| 110 | 110 | |
| 111 | 111 | $output = ''; |
| 112 | - if( is_array( $current ) ) { |
|
| 113 | - if( in_array( $value, $current ) ) { |
|
| 112 | + if ( is_array( $current ) ) { |
|
| 113 | + if ( in_array( $value, $current ) ) { |
|
| 114 | 114 | $output = __checked_selected_helper( true, true, false, $type ); |
| 115 | 115 | } |
| 116 | 116 | } else { |
| 117 | 117 | $output = __checked_selected_helper( $value, $current, false, $type ); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if( $echo ) { |
|
| 120 | + if ( $echo ) { |
|
| 121 | 121 | echo $output; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
| 128 | -if( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
| 128 | +if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that. |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | function gravityview_strip_whitespace( $string ) { |
| 173 | 173 | $string = normalize_whitespace( $string ); |
| 174 | - return preg_replace('/[\r\n\t ]+/', ' ', $string ); |
|
| 174 | + return preg_replace( '/[\r\n\t ]+/', ' ', $string ); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @return string Included file contents |
| 186 | 186 | */ |
| 187 | 187 | function gravityview_ob_include( $file_path, $object = NULL ) { |
| 188 | - if( ! file_exists( $file_path ) ) { |
|
| 188 | + if ( ! file_exists( $file_path ) ) { |
|
| 189 | 189 | gravityview()->log->error( 'File path does not exist. {path}', array( 'path' => $file_path ) ); |
| 190 | 190 | return ''; |
| 191 | 191 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | $width = $height * 0.7586206897; |
| 211 | 211 | |
| 212 | - if( function_exists('is_rtl') && is_rtl() ) { |
|
| 212 | + if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
| 213 | 213 | $style = 'margin:10px 10px 10px 0;'; |
| 214 | 214 | $css_class = is_string( $css_class ) ? $css_class : 'alignright'; |
| 215 | 215 | } else { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $css_class = is_string( $css_class ) ? $css_class : 'alignleft'; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - return '<img src="'. esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) .'" class="'. gravityview_sanitize_html_class( $css_class ).'" height="'.intval( $height ).'" width="'.round( $width, 2 ).'" alt="The GravityView Astronaut Says:" style="'.$style.'" />'; |
|
| 220 | + return '<img src="' . esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) . '" class="' . gravityview_sanitize_html_class( $css_class ) . '" height="' . intval( $height ) . '" width="' . round( $width, 2 ) . '" alt="The GravityView Astronaut Says:" style="' . $style . '" />'; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | function gravityview_number_format( $number, $decimals = '' ) { |
| 241 | 241 | global $wp_locale; |
| 242 | 242 | |
| 243 | - if( '' === $decimals ) { |
|
| 243 | + if ( '' === $decimals ) { |
|
| 244 | 244 | |
| 245 | - $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.'; |
|
| 245 | + $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.'; |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Calculate the position of the decimal point in the number |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $parts = parse_url( $value ); |
| 272 | 272 | |
| 273 | 273 | // No domain? Strange...show the original text. |
| 274 | - if( empty( $parts['host'] ) ) { |
|
| 274 | + if ( empty( $parts[ 'host' ] ) ) { |
|
| 275 | 275 | return $value; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n |
| 285 | 285 | * If true: `http://example.com => example.com` |
| 286 | 286 | */ |
| 287 | - if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) { |
|
| 287 | + if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) { |
|
| 288 | 288 | |
| 289 | - if( isset( $parts['scheme'] ) ) { |
|
| 290 | - $return .= $parts['scheme']; |
|
| 289 | + if ( isset( $parts[ 'scheme' ] ) ) { |
|
| 290 | + $return .= $parts[ 'scheme' ]; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // The domain, which may contain a subdomain |
| 296 | - $domain = $parts['host']; |
|
| 296 | + $domain = $parts[ 'host' ]; |
|
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * @filter `gravityview_anchor_text_stripwww` Strip www from the domain? |
@@ -301,10 +301,10 @@ discard block |
||
| 301 | 301 | * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n |
| 302 | 302 | * If true: `www.example.com => example.com` |
| 303 | 303 | */ |
| 304 | - $strip_www = apply_filters('gravityview_anchor_text_stripwww', true ); |
|
| 304 | + $strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true ); |
|
| 305 | 305 | |
| 306 | - if( $strip_www ) { |
|
| 307 | - $domain = str_replace('www.', '', $domain ); |
|
| 306 | + if ( $strip_www ) { |
|
| 307 | + $domain = str_replace( 'www.', '', $domain ); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | * If true: `http://demo.example.com => example.com` \n |
| 315 | 315 | * If false: `http://demo.example.com => demo.example.com` |
| 316 | 316 | */ |
| 317 | - $strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true); |
|
| 317 | + $strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true ); |
|
| 318 | 318 | |
| 319 | - if( $strip_subdomains ) { |
|
| 319 | + if ( $strip_subdomains ) { |
|
| 320 | 320 | |
| 321 | - $domain = _gravityview_strip_subdomain( $parts['host'] ); |
|
| 321 | + $domain = _gravityview_strip_subdomain( $parts[ 'host' ] ); |
|
| 322 | 322 | |
| 323 | 323 | } |
| 324 | 324 | |
@@ -332,12 +332,12 @@ discard block |
||
| 332 | 332 | * If true: `http://example.com/sub/directory/page.html => example.com` \n |
| 333 | 333 | * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html` |
| 334 | 334 | */ |
| 335 | - $root_only = apply_filters('gravityview_anchor_text_rootonly', true); |
|
| 335 | + $root_only = apply_filters( 'gravityview_anchor_text_rootonly', true ); |
|
| 336 | 336 | |
| 337 | - if( empty( $root_only ) ) { |
|
| 337 | + if ( empty( $root_only ) ) { |
|
| 338 | 338 | |
| 339 | - if( isset( $parts['path'] ) ) { |
|
| 340 | - $return .= $parts['path']; |
|
| 339 | + if ( isset( $parts[ 'path' ] ) ) { |
|
| 340 | + $return .= $parts[ 'path' ]; |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -347,12 +347,12 @@ discard block |
||
| 347 | 347 | * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n |
| 348 | 348 | * If true: `http://example.com/?query=example => example.com` |
| 349 | 349 | */ |
| 350 | - $strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true ); |
|
| 350 | + $strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true ); |
|
| 351 | 351 | |
| 352 | - if( empty( $strip_query_string ) ) { |
|
| 352 | + if ( empty( $strip_query_string ) ) { |
|
| 353 | 353 | |
| 354 | - if( isset( $parts['query'] ) ) { |
|
| 355 | - $return .= '?'.$parts['query']; |
|
| 354 | + if ( isset( $parts[ 'query' ] ) ) { |
|
| 355 | + $return .= '?' . $parts[ 'query' ]; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | } |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { |
| 371 | 371 | |
| 372 | - if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
| 373 | - return $matches['domain']; |
|
| 372 | + if ( preg_match( "/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
| 373 | + return $matches[ 'domain' ]; |
|
| 374 | 374 | } else { |
| 375 | 375 | return $string_maybe_has_subdomain; |
| 376 | 376 | } |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | if ( in_array( $value, array( 'yes', 'true' ), true ) ) { |
| 441 | 441 | $value = true; |
| 442 | - } else if( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
| 442 | + } else if ( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
| 443 | 443 | $value = false; |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = 0 ) { |
| 470 | 470 | |
| 471 | - if( ! is_string( $value ) ) { |
|
| 471 | + if ( ! is_string( $value ) ) { |
|
| 472 | 472 | return $value; |
| 473 | 473 | } |
| 474 | 474 | |
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // There was a JSON error (PHP 5.3+) |
| 482 | - if( function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error() ) { |
|
| 482 | + if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { |
|
| 483 | 483 | return $value; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | // It wasn't JSON (PHP < 5.3 fallback) |
| 487 | - if( is_null( $decoded ) ) { |
|
| 487 | + if ( is_null( $decoded ) ) { |
|
| 488 | 488 | return $value; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | // Use the original function, if exists. |
| 509 | 509 | // Requires WP 4.4+ |
| 510 | - if( function_exists( 'map_deep') ) { |
|
| 510 | + if ( function_exists( 'map_deep' ) ) { |
|
| 511 | 511 | return map_deep( $value, $callback ); |
| 512 | 512 | } |
| 513 | 513 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | $exploded = explode( '.', "{$field_id}" ); |
| 574 | 574 | |
| 575 | - return isset( $exploded[1] ) ? intval( $exploded[1] ) : false; |
|
| 575 | + return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -613,13 +613,13 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | $args = apply_filters( 'gravityview_get_terms_choices_args', $args ); |
| 615 | 615 | |
| 616 | - $terms = get_terms( $args['taxonomy'], $args ); |
|
| 616 | + $terms = get_terms( $args[ 'taxonomy' ], $args ); |
|
| 617 | 617 | |
| 618 | 618 | $choices = array(); |
| 619 | 619 | |
| 620 | 620 | if ( is_array( $terms ) ) { |
| 621 | 621 | foreach ( $terms as $term_id => $term_name ) { |
| 622 | - $choices[] = array( |
|
| 622 | + $choices[ ] = array( |
|
| 623 | 623 | 'text' => $term_name, |
| 624 | 624 | 'value' => $term_id |
| 625 | 625 | ); |
@@ -643,21 +643,21 @@ discard block |
||
| 643 | 643 | function _gravityview_process_posted_fields() { |
| 644 | 644 | $fields = array(); |
| 645 | 645 | |
| 646 | - if( !empty( $_POST['gv_fields'] ) ) { |
|
| 647 | - if ( ! is_array( $_POST['gv_fields'] ) ) { |
|
| 646 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
| 647 | + if ( ! is_array( $_POST[ 'gv_fields' ] ) ) { |
|
| 648 | 648 | |
| 649 | 649 | // We are not using parse_str() due to max_input_vars limitation with large View configurations |
| 650 | 650 | $fields_holder = array(); |
| 651 | - GVCommon::gv_parse_str( $_POST['gv_fields'], $fields_holder ); |
|
| 651 | + GVCommon::gv_parse_str( $_POST[ 'gv_fields' ], $fields_holder ); |
|
| 652 | 652 | |
| 653 | - if ( isset( $fields_holder['fields'] ) ) { |
|
| 654 | - $fields = $fields_holder['fields']; |
|
| 653 | + if ( isset( $fields_holder[ 'fields' ] ) ) { |
|
| 654 | + $fields = $fields_holder[ 'fields' ]; |
|
| 655 | 655 | } else { |
| 656 | 656 | gravityview()->log->error( 'No `fields` key was found after parsing $fields string', array( 'data' => $fields_holder ) ); |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | } else { |
| 660 | - $fields = $_POST['gv_fields']; |
|
| 660 | + $fields = $_POST[ 'gv_fields' ]; |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function add_downloads_data_filters() { |
| 68 | 68 | |
| 69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 70 | 70 | |
| 71 | - if ( ! $downloads_data ) { |
|
| 71 | + if ( ! $downloads_data ) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function add_admin_menu() { |
| 99 | 99 | |
| 100 | - $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 100 | + $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 101 | 101 | |
| 102 | 102 | $menu_text = sprintf( '<span title="%s">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
| 103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | - * |
|
| 115 | + * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | + * |
|
| 117 | 117 | * @param array $notice |
| 118 | 118 | * |
| 119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
| 122 | 122 | |
| 123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
| 124 | - return $notice; |
|
| 125 | - } |
|
| 124 | + return $notice; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -162,43 +162,43 @@ discard block |
||
| 162 | 162 | * Get downloads data from transient or from API; save transient after getting data from API |
| 163 | 163 | * |
| 164 | 164 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
| 165 | - * @type array $info { |
|
| 166 | - * @type string $id int 17 |
|
| 167 | - * @type string $slug Extension slug |
|
| 168 | - * @type string $title Extension title |
|
| 169 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 170 | - * @type string $modified_date |
|
| 171 | - * @type string $status |
|
| 172 | - * @type string $link URL to public plugin page |
|
| 173 | - * @type string $content |
|
| 174 | - * @type string $excerpt |
|
| 175 | - * @type string $thumbnail URL to thumbnail |
|
| 176 | - * @type array $category Taxonomy details for the plugin's category { |
|
| 177 | - * @type int $term_id => int 30 |
|
| 178 | - * @type string $name => string 'Plugins' (length=7) |
|
| 179 | - * @type string $slug => string 'plugins' (length=7) |
|
| 180 | - * @type int $term_group => int 0 |
|
| 181 | - * @type int $term_taxonomy_id => int 30 |
|
| 182 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
| 183 | - * @type string $description => string '' (length=0) |
|
| 184 | - * @type int $parent => int 0 |
|
| 185 | - * @type int $count => int 4 |
|
| 186 | - * @type string $filter => string 'raw' (length=3) |
|
| 187 | - * } |
|
| 188 | - * @type array $tags {see $category above} |
|
| 189 | - * @type string $textdomain string 'gravityview' (length=11) |
|
| 190 | - * } |
|
| 191 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 192 | - * @type array $licensing { |
|
| 193 | - * @type bool $enabled Is licensing enabled for the extension |
|
| 194 | - * @type string $version Version number |
|
| 195 | - * @type string $exp_unit Expiration unit ('years') |
|
| 196 | - * @type string $exp_length Expiration length ('1') |
|
| 197 | - * } |
|
| 198 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 199 | - * @type string $file string URL of the file download |
|
| 200 | - * } |
|
| 201 | - * } |
|
| 165 | + * @type array $info { |
|
| 166 | + * @type string $id int 17 |
|
| 167 | + * @type string $slug Extension slug |
|
| 168 | + * @type string $title Extension title |
|
| 169 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 170 | + * @type string $modified_date |
|
| 171 | + * @type string $status |
|
| 172 | + * @type string $link URL to public plugin page |
|
| 173 | + * @type string $content |
|
| 174 | + * @type string $excerpt |
|
| 175 | + * @type string $thumbnail URL to thumbnail |
|
| 176 | + * @type array $category Taxonomy details for the plugin's category { |
|
| 177 | + * @type int $term_id => int 30 |
|
| 178 | + * @type string $name => string 'Plugins' (length=7) |
|
| 179 | + * @type string $slug => string 'plugins' (length=7) |
|
| 180 | + * @type int $term_group => int 0 |
|
| 181 | + * @type int $term_taxonomy_id => int 30 |
|
| 182 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
| 183 | + * @type string $description => string '' (length=0) |
|
| 184 | + * @type int $parent => int 0 |
|
| 185 | + * @type int $count => int 4 |
|
| 186 | + * @type string $filter => string 'raw' (length=3) |
|
| 187 | + * } |
|
| 188 | + * @type array $tags {see $category above} |
|
| 189 | + * @type string $textdomain string 'gravityview' (length=11) |
|
| 190 | + * } |
|
| 191 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 192 | + * @type array $licensing { |
|
| 193 | + * @type bool $enabled Is licensing enabled for the extension |
|
| 194 | + * @type string $version Version number |
|
| 195 | + * @type string $exp_unit Expiration unit ('years') |
|
| 196 | + * @type string $exp_length Expiration length ('1') |
|
| 197 | + * } |
|
| 198 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 199 | + * @type string $file string URL of the file download |
|
| 200 | + * } |
|
| 201 | + * } |
|
| 202 | 202 | */ |
| 203 | 203 | public function get_downloads_data() { |
| 204 | 204 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | ) ); |
| 227 | 227 | |
| 228 | 228 | if ( is_wp_error( $response ) ) { |
| 229 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 229 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 230 | 230 | return $response; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | <div class="gv-admin-installer-notice notice inline error"> |
| 280 | 280 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
| 281 | 281 | <?php |
| 282 | - if ( is_wp_error( $downloads_data ) ) { |
|
| 283 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 284 | - } |
|
| 285 | - ?> |
|
| 282 | + if ( is_wp_error( $downloads_data ) ) { |
|
| 283 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 284 | + } |
|
| 285 | + ?> |
|
| 286 | 286 | </div> |
| 287 | 287 | </div> |
| 288 | 288 | <?php |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | protected function render_download( $download, $wp_plugins ) { |
| 339 | 339 | |
| 340 | 340 | |
| 341 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 341 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 342 | 342 | |
| 343 | - $download_info = $details['download_info']; |
|
| 343 | + $download_info = $details['download_info']; |
|
| 344 | 344 | |
| 345 | 345 | ?> |
| 346 | 346 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -362,43 +362,43 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | <div class="addon-excerpt"><?php |
| 364 | 364 | |
| 365 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 365 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 366 | 366 | |
| 367 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 368 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 369 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 367 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 368 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 369 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 370 | 370 | |
| 371 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 372 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 371 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 372 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 373 | 373 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
| 374 | 374 | |
| 375 | 375 | echo wpautop( $excerpt ); |
| 376 | - ?></div> |
|
| 376 | + ?></div> |
|
| 377 | 377 | </div> |
| 378 | 378 | </div> |
| 379 | 379 | <?php |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
| 383 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 384 | - * |
|
| 383 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 384 | + * |
|
| 385 | 385 | * @param array $download Single download, as returned by {@see get_downloads_data} |
| 386 | 386 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
| 387 | 387 | * |
| 388 | 388 | * @return array { |
| 389 | - * @type array $download_info |
|
| 390 | - * @type string $plugin_path |
|
| 391 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 392 | - * @type string $status_label |
|
| 393 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 394 | - * @type string $button_class CSS class to use for the button |
|
| 395 | - * @type string $button_label Text to use for the download's anchor link |
|
| 396 | - * @type string $href URL for the download's button |
|
| 397 | - * @type bool $spinner Whether to show the spinner icon |
|
| 398 | - * @type string $item_class CSS class for the download container |
|
| 399 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 400 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 401 | - * } |
|
| 389 | + * @type array $download_info |
|
| 390 | + * @type string $plugin_path |
|
| 391 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 392 | + * @type string $status_label |
|
| 393 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 394 | + * @type string $button_class CSS class to use for the button |
|
| 395 | + * @type string $button_label Text to use for the download's anchor link |
|
| 396 | + * @type string $href URL for the download's button |
|
| 397 | + * @type bool $spinner Whether to show the spinner icon |
|
| 398 | + * @type string $item_class CSS class for the download container |
|
| 399 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 400 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 401 | + * } |
|
| 402 | 402 | */ |
| 403 | 403 | private function get_download_display_details( $download, $wp_plugins ) { |
| 404 | 404 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | 'slug' => '', |
| 410 | 410 | 'excerpt' => '', |
| 411 | 411 | 'link' => '', |
| 412 | - 'coming_soon' => false, |
|
| 412 | + 'coming_soon' => false, |
|
| 413 | 413 | 'installer_title' => null, // May not be defined |
| 414 | 414 | 'installer_excerpt' => null, // May not be defined |
| 415 | 415 | ) ); |
@@ -451,14 +451,14 @@ discard block |
||
| 451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | - $spinner = false; |
|
| 456 | - $status = 'notinstalled'; |
|
| 457 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 458 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
| 459 | - $button_class = 'button-primary button-large'; |
|
| 460 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 461 | - } |
|
| 454 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | + $spinner = false; |
|
| 456 | + $status = 'notinstalled'; |
|
| 457 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 458 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
| 459 | + $button_class = 'button-primary button-large'; |
|
| 460 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | 463 | // Access but the plugin is not installed |
| 464 | 464 | elseif ( ! $wp_plugin ) { |
@@ -498,18 +498,18 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | /** |
| 504 | - * Returns the base price for an extension |
|
| 505 | - * |
|
| 504 | + * Returns the base price for an extension |
|
| 505 | + * |
|
| 506 | 506 | * @param array $download |
| 507 | 507 | * |
| 508 | 508 | * @return float Base price for an extension. If not for sale separately, returns 0 |
| 509 | 509 | */ |
| 510 | 510 | private function get_download_base_price( $download ) { |
| 511 | 511 | |
| 512 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 512 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 513 | 513 | $base_price = \GFCommon::to_number( $base_price ); |
| 514 | 514 | |
| 515 | 515 | unset( $download['pricing']['amount'] ); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | return floatval( $base_price ); |
| 523 | - } |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | 525 | /** |
| 526 | 526 | * Handle AJAX request to activate extension |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
| 540 | 540 | wp_send_json_error( array( |
| 541 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 542 | - ) ); |
|
| 541 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 542 | + ) ); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | wp_send_json_success(); |
@@ -560,10 +560,10 @@ discard block |
||
| 560 | 560 | deactivate_plugins( $data['path'] ); |
| 561 | 561 | |
| 562 | 562 | if( is_plugin_active( $data['path'] ) ) { |
| 563 | - wp_send_json_error( array( |
|
| 564 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 565 | - ) ); |
|
| 566 | - } |
|
| 563 | + wp_send_json_error( array( |
|
| 564 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 565 | + ) ); |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | wp_send_json_success(); |
| 569 | 569 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function register_noconflict( $items ) { |
| 55 | 55 | |
| 56 | - $items[] = 'gravityview-admin-installer'; |
|
| 56 | + $items[ ] = 'gravityview-admin-installer'; |
|
| 57 | 57 | |
| 58 | 58 | return $items; |
| 59 | 59 | } |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
| 75 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
| 76 | 76 | foreach ( $downloads_data as $extension ) { |
| 77 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
| 77 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return (object) array( |
|
| 82 | - 'slug' => $extension['info']['slug'], |
|
| 83 | - 'name' => $extension['info']['title'], |
|
| 84 | - 'version' => $extension['licensing']['version'], |
|
| 85 | - 'download_link' => $extension['files'][0]['file'], |
|
| 81 | + return (object)array( |
|
| 82 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
| 83 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
| 84 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
| 85 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | foreach ( $all_plugins as $path => $plugin ) { |
| 146 | 146 | |
| 147 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
| 147 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
| 148 | 148 | continue; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
| 151 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
| 152 | 152 | 'path' => $path, |
| 153 | - 'version' => $plugin['Version'], |
|
| 153 | + 'version' => $plugin[ 'Version' ], |
|
| 154 | 154 | 'activated' => is_plugin_active( $path ) |
| 155 | 155 | ); |
| 156 | 156 | } |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
| 234 | 234 | |
| 235 | - if ( empty( $downloads_data['products'] ) ) { |
|
| 235 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
| 236 | 236 | return array(); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
| 239 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
| 240 | 240 | |
| 241 | - return $downloads_data['products']; |
|
| 241 | + return $downloads_data[ 'products' ]; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | foreach ( $downloads_data as $extension ) { |
| 313 | 313 | |
| 314 | - if ( empty( $extension['info'] ) ) { |
|
| 314 | + if ( empty( $extension[ 'info' ] ) ) { |
|
| 315 | 315 | continue; |
| 316 | 316 | } |
| 317 | 317 | |
@@ -340,29 +340,29 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
| 342 | 342 | |
| 343 | - $download_info = $details['download_info']; |
|
| 343 | + $download_info = $details[ 'download_info' ]; |
|
| 344 | 344 | |
| 345 | 345 | ?> |
| 346 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
| 346 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
| 347 | 347 | <div class="addon-inner"> |
| 348 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
| 349 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
| 348 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
| 349 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
| 350 | 350 | <div> |
| 351 | - <?php if( $details['status_label'] ) { ?> |
|
| 352 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
| 353 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
| 351 | + <?php if ( $details[ 'status_label' ] ) { ?> |
|
| 352 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
| 353 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
| 354 | 354 | </div> |
| 355 | 355 | <?php } ?> |
| 356 | 356 | |
| 357 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
| 358 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
| 359 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
| 357 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
| 358 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
| 359 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
| 360 | 360 | </a> |
| 361 | 361 | </div> |
| 362 | 362 | |
| 363 | 363 | <div class="addon-excerpt"><?php |
| 364 | 364 | |
| 365 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 365 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
| 366 | 366 | |
| 367 | 367 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
| 368 | 368 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | private function get_download_display_details( $download, $wp_plugins ) { |
| 404 | 404 | |
| 405 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
| 405 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
| 406 | 406 | 'thumbnail' => '', |
| 407 | 407 | 'title' => '', |
| 408 | 408 | 'textdomain' => '', |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | 'installer_excerpt' => null, // May not be defined |
| 415 | 415 | ) ); |
| 416 | 416 | |
| 417 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
| 417 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
| 418 | 418 | |
| 419 | - $has_access = ! empty( $download['files'] ); |
|
| 419 | + $has_access = ! empty( $download[ 'files' ] ); |
|
| 420 | 420 | $spinner = true; |
| 421 | 421 | $href = $plugin_path = '#'; |
| 422 | 422 | $status = $item_class = $button_title = $button_class = ''; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
| 427 | 427 | |
| 428 | 428 | // The license is not active - no matter what level, this should not work |
| 429 | - if( ! $is_active && empty( $base_price ) ) { |
|
| 429 | + if ( ! $is_active && empty( $base_price ) ) { |
|
| 430 | 430 | $spinner = false; |
| 431 | 431 | $button_class = 'disabled disabled-license'; |
| 432 | 432 | $button_label = sprintf( __( 'Active %s License is Required.', 'gravityview' ), $required_license ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $status_label = ''; |
| 439 | 439 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
| 440 | 440 | $button_class = 'button-primary button-large'; |
| 441 | - $href = $download_info['link']; |
|
| 441 | + $href = $download_info[ 'link' ]; |
|
| 442 | 442 | $item_class = 'featured'; |
| 443 | 443 | } |
| 444 | 444 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 454 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
| 455 | 455 | $spinner = false; |
| 456 | 456 | $status = 'notinstalled'; |
| 457 | 457 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -466,8 +466,8 @@ discard block |
||
| 466 | 466 | $href = add_query_arg( |
| 467 | 467 | array( |
| 468 | 468 | 'action' => 'install-plugin', |
| 469 | - 'plugin' => $download_info['slug'], |
|
| 470 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
| 469 | + 'plugin' => $download_info[ 'slug' ], |
|
| 470 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
| 471 | 471 | ), |
| 472 | 472 | self_admin_url( 'update.php' ) |
| 473 | 473 | ); |
@@ -479,25 +479,25 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // Access and the plugin is installed but not active |
| 482 | - elseif ( false === $wp_plugin['activated'] ) { |
|
| 482 | + elseif ( false === $wp_plugin[ 'activated' ] ) { |
|
| 483 | 483 | $status = 'inactive'; |
| 484 | 484 | $status_label = __( 'Inactive', 'gravityview' ); |
| 485 | 485 | $button_label = __( 'Activate', 'gravityview' ); |
| 486 | - $plugin_path = $wp_plugin['path']; |
|
| 486 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // Access and the plugin is installed and active |
| 491 | 491 | else { |
| 492 | 492 | |
| 493 | - $plugin_path = $wp_plugin['path']; |
|
| 493 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
| 494 | 494 | $status = 'active'; |
| 495 | 495 | $status_label = __( 'Active', 'gravityview' ); |
| 496 | 496 | $button_label = __( 'Deactivate', 'gravityview' ); |
| 497 | 497 | |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
| 500 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -512,11 +512,11 @@ discard block |
||
| 512 | 512 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
| 513 | 513 | $base_price = \GFCommon::to_number( $base_price ); |
| 514 | 514 | |
| 515 | - unset( $download['pricing']['amount'] ); |
|
| 515 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
| 516 | 516 | |
| 517 | 517 | // Price options array, not single price |
| 518 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
| 519 | - $base_price = array_shift( $download['pricing'] ); |
|
| 518 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
| 519 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | return floatval( $base_price ); |
@@ -530,13 +530,13 @@ discard block |
||
| 530 | 530 | public function activate_download() { |
| 531 | 531 | $data = \GV\Utils::_POST( 'data', array() ); |
| 532 | 532 | |
| 533 | - if ( empty( $data['path'] ) ) { |
|
| 533 | + if ( empty( $data[ 'path' ] ) ) { |
|
| 534 | 534 | return; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - $result = activate_plugin( $data['path'] ); |
|
| 537 | + $result = activate_plugin( $data[ 'path' ] ); |
|
| 538 | 538 | |
| 539 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
| 539 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
| 540 | 540 | wp_send_json_error( array( |
| 541 | 541 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
| 542 | 542 | ) ); |
@@ -553,13 +553,13 @@ discard block |
||
| 553 | 553 | public function deactivate_download() { |
| 554 | 554 | $data = \GV\Utils::_POST( 'data', array() ); |
| 555 | 555 | |
| 556 | - if ( empty( $data['path'] ) ) { |
|
| 556 | + if ( empty( $data[ 'path' ] ) ) { |
|
| 557 | 557 | return; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - deactivate_plugins( $data['path'] ); |
|
| 560 | + deactivate_plugins( $data[ 'path' ] ); |
|
| 561 | 561 | |
| 562 | - if( is_plugin_active( $data['path'] ) ) { |
|
| 562 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
| 563 | 563 | wp_send_json_error( array( |
| 564 | 564 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
| 565 | 565 | ) ); |
@@ -449,9 +449,7 @@ |
||
| 449 | 449 | $button_label = sprintf( __( 'Upgrade to %s for Access', 'gravityview' ), $required_license ); |
| 450 | 450 | $button_class = 'button-primary button-large'; |
| 451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 452 | - } |
|
| 453 | - |
|
| 454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 452 | + } elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | 453 | $spinner = false; |
| 456 | 454 | $status = 'notinstalled'; |
| 457 | 455 | $status_label = __( 'Coming Soon', 'gravityview' ); |