@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( empty( $logout_redirect ) ) { |
|
| 37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | - } |
|
| 36 | + if ( empty( $logout_redirect ) ) { |
|
| 37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - // Add user_logout action to logout url. |
|
| 42 | - $logout_redirect = add_query_arg( |
|
| 43 | - array( |
|
| 44 | - 'give_action' => 'user_logout', |
|
| 45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | - ), |
|
| 48 | - home_url('/') |
|
| 49 | - ); |
|
| 41 | + // Add user_logout action to logout url. |
|
| 42 | + $logout_redirect = add_query_arg( |
|
| 43 | + array( |
|
| 44 | + 'give_action' => 'user_logout', |
|
| 45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | + ), |
|
| 48 | + home_url('/') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | 51 | $give_login_redirect = $login_redirect; |
| 52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,23 +136,23 @@ discard block |
||
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | 138 | function give_process_user_logout( $data ) { |
| 139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 140 | 140 | |
| 141 | - // Prevent occurring of any custom action on wp_logout. |
|
| 142 | - remove_all_actions( 'wp_logout' ); |
|
| 141 | + // Prevent occurring of any custom action on wp_logout. |
|
| 142 | + remove_all_actions( 'wp_logout' ); |
|
| 143 | 143 | |
| 144 | - // Before logout give action. |
|
| 145 | - do_action( 'give_before_user_logout' ); |
|
| 144 | + // Before logout give action. |
|
| 145 | + do_action( 'give_before_user_logout' ); |
|
| 146 | 146 | |
| 147 | - // Logout user. |
|
| 148 | - wp_logout(); |
|
| 147 | + // Logout user. |
|
| 148 | + wp_logout(); |
|
| 149 | 149 | |
| 150 | - // After logout give action. |
|
| 151 | - do_action( 'give_after_user_logout' ); |
|
| 150 | + // After logout give action. |
|
| 151 | + do_action( 'give_after_user_logout' ); |
|
| 152 | 152 | |
| 153 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 154 | - give_die(); |
|
| 155 | - } |
|
| 153 | + wp_redirect( $data['give_logout_redirect'] ); |
|
| 154 | + give_die(); |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | * Determines whether results should be displayed in XML or JSON |
| 1438 | 1438 | * |
| 1439 | 1439 | * @since 1.1 |
| 1440 | - * @access public |
|
| 1440 | + * @access public |
|
| 1441 | 1441 | * |
| 1442 | 1442 | * @return mixed|void |
| 1443 | 1443 | */ |
@@ -1455,7 +1455,7 @@ discard block |
||
| 1455 | 1455 | * |
| 1456 | 1456 | * @access private |
| 1457 | 1457 | * @since 1.1 |
| 1458 | - * |
|
| 1458 | + * |
|
| 1459 | 1459 | * @global Give_Logging $give_logs |
| 1460 | 1460 | * @global WP_Query $wp_query |
| 1461 | 1461 | * |
@@ -1468,15 +1468,15 @@ discard block |
||
| 1468 | 1468 | return; |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | - /** |
|
| 1472 | - * @var Give_Logging $give_logs |
|
| 1473 | - */ |
|
| 1471 | + /** |
|
| 1472 | + * @var Give_Logging $give_logs |
|
| 1473 | + */ |
|
| 1474 | 1474 | global $give_logs; |
| 1475 | 1475 | |
| 1476 | - /** |
|
| 1477 | - * @var WP_Query $wp_query |
|
| 1478 | - */ |
|
| 1479 | - global $wp_query; |
|
| 1476 | + /** |
|
| 1477 | + * @var WP_Query $wp_query |
|
| 1478 | + */ |
|
| 1479 | + global $wp_query; |
|
| 1480 | 1480 | |
| 1481 | 1481 | $query = array( |
| 1482 | 1482 | 'give-api' => $wp_query->query_vars['give-api'], |
@@ -1534,9 +1534,9 @@ discard block |
||
| 1534 | 1534 | * @param int $status_code |
| 1535 | 1535 | */ |
| 1536 | 1536 | public function output( $status_code = 200 ) { |
| 1537 | - /** |
|
| 1538 | - * @var WP_Query $wp_query |
|
| 1539 | - */ |
|
| 1537 | + /** |
|
| 1538 | + * @var WP_Query $wp_query |
|
| 1539 | + */ |
|
| 1540 | 1540 | global $wp_query; |
| 1541 | 1541 | |
| 1542 | 1542 | $format = $this->get_output_format(); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | //validate display_style and float_labels value |
| 93 | 93 | if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
| 94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 94 | + || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | 97 | $atts[ $key ] = ''; |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function give_login_form_shortcode( $atts, $content = null ) { |
| 171 | 171 | $atts = shortcode_atts( array( |
| 172 | - // Add backward compatibility for redirect attribute. |
|
| 173 | - 'redirect' => '', |
|
| 172 | + // Add backward compatibility for redirect attribute. |
|
| 173 | + 'redirect' => '', |
|
| 174 | 174 | |
| 175 | 175 | 'login-redirect' => '', |
| 176 | 176 | 'logout-redirect' => '', |
| 177 | 177 | ), $atts, 'give_login' ); |
| 178 | 178 | |
| 179 | - // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 179 | + // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | + $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 181 | 181 | |
| 182 | 182 | return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
| 183 | 183 | } |
@@ -781,7 +781,7 @@ |
||
| 781 | 781 | foreach ( $prices as $price ) { |
| 782 | 782 | if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
| 783 | 783 | $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
| 784 | - break; |
|
| 784 | + break; |
|
| 785 | 785 | }; |
| 786 | 786 | } |
| 787 | 787 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public $error = ''; |
| 24 | 24 | |
| 25 | 25 | private $verify_throttle; |
| 26 | - private $token_expiration; |
|
| 26 | + private $token_expiration; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Give_Email_Access constructor. |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return bool |
| 244 | 244 | */ |
| 245 | 245 | function is_valid_verify_key( $token ) { |
| 246 | - /* @var WPDB $wpdb */ |
|
| 246 | + /* @var WPDB $wpdb */ |
|
| 247 | 247 | global $wpdb; |
| 248 | 248 | |
| 249 | 249 | // See if the verify_key exists |
@@ -42,16 +42,16 @@ |
||
| 42 | 42 | 'minWidth' => 320, |
| 43 | 43 | 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ), |
| 44 | 44 | ), |
| 45 | - array( |
|
| 46 | - 'type' => 'container', |
|
| 47 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ), |
|
| 48 | - ), |
|
| 49 | - array( |
|
| 50 | - 'type' => 'textbox', |
|
| 51 | - 'name' => 'logout-redirect', |
|
| 52 | - 'minWidth' => 320, |
|
| 53 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ), |
|
| 54 | - ), |
|
| 45 | + array( |
|
| 46 | + 'type' => 'container', |
|
| 47 | + 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ), |
|
| 48 | + ), |
|
| 49 | + array( |
|
| 50 | + 'type' => 'textbox', |
|
| 51 | + 'name' => 'logout-redirect', |
|
| 52 | + 'minWidth' => 320, |
|
| 53 | + 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ), |
|
| 54 | + ), |
|
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -248,8 +248,8 @@ |
||
| 248 | 248 | |
| 249 | 249 | // do not reindex array! |
| 250 | 250 | $field['options'] = array( |
| 251 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
| 252 | - ) + $field['options']; |
|
| 251 | + '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
| 252 | + ) + $field['options']; |
|
| 253 | 253 | |
| 254 | 254 | foreach ( $field['options'] as $value => $text ) { |
| 255 | 255 | $new_listbox['values'][] = array( |
@@ -13,330 +13,330 @@ |
||
| 13 | 13 | * @version 1.6 |
| 14 | 14 | */ |
| 15 | 15 | class EDD_SL_Plugin_Updater { |
| 16 | - private $api_url = ''; |
|
| 17 | - private $api_data = array(); |
|
| 18 | - private $name = ''; |
|
| 19 | - private $slug = ''; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Class constructor. |
|
| 23 | - * |
|
| 24 | - * @uses plugin_basename() |
|
| 25 | - * @uses hook() |
|
| 26 | - * |
|
| 27 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
| 28 | - * @param string $_plugin_file Path to the plugin file. |
|
| 29 | - * @param array $_api_data Optional data to send with API calls. |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
| 33 | - $this->api_url = trailingslashit( $_api_url ); |
|
| 34 | - $this->api_data = $_api_data; |
|
| 35 | - $this->name = plugin_basename( $_plugin_file ); |
|
| 36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
| 37 | - $this->version = $_api_data['version']; |
|
| 38 | - |
|
| 39 | - // Set up hooks. |
|
| 40 | - $this->init(); |
|
| 41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Set up WordPress filters to hook into WP's update process. |
|
| 46 | - * |
|
| 47 | - * @uses add_filter() |
|
| 48 | - * |
|
| 49 | - * @return void |
|
| 50 | - */ |
|
| 51 | - public function init() { |
|
| 16 | + private $api_url = ''; |
|
| 17 | + private $api_data = array(); |
|
| 18 | + private $name = ''; |
|
| 19 | + private $slug = ''; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Class constructor. |
|
| 23 | + * |
|
| 24 | + * @uses plugin_basename() |
|
| 25 | + * @uses hook() |
|
| 26 | + * |
|
| 27 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
| 28 | + * @param string $_plugin_file Path to the plugin file. |
|
| 29 | + * @param array $_api_data Optional data to send with API calls. |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
| 33 | + $this->api_url = trailingslashit( $_api_url ); |
|
| 34 | + $this->api_data = $_api_data; |
|
| 35 | + $this->name = plugin_basename( $_plugin_file ); |
|
| 36 | + $this->slug = basename( $_plugin_file, '.php' ); |
|
| 37 | + $this->version = $_api_data['version']; |
|
| 38 | + |
|
| 39 | + // Set up hooks. |
|
| 40 | + $this->init(); |
|
| 41 | + add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Set up WordPress filters to hook into WP's update process. |
|
| 46 | + * |
|
| 47 | + * @uses add_filter() |
|
| 48 | + * |
|
| 49 | + * @return void |
|
| 50 | + */ |
|
| 51 | + public function init() { |
|
| 52 | 52 | |
| 53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
| 53 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 54 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
| 55 | 55 | |
| 56 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
| 57 | - } |
|
| 56 | + add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
| 61 | - * |
|
| 62 | - * This function dives into the update API just when WordPress creates its update array, |
|
| 63 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
| 64 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
| 65 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
| 66 | - * |
|
| 67 | - * @uses api_request() |
|
| 68 | - * |
|
| 69 | - * @param array $_transient_data Update array build by WordPress. |
|
| 70 | - * @return array Modified update array with custom plugin data. |
|
| 71 | - */ |
|
| 72 | - function check_update( $_transient_data ) { |
|
| 59 | + /** |
|
| 60 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
| 61 | + * |
|
| 62 | + * This function dives into the update API just when WordPress creates its update array, |
|
| 63 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
| 64 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
| 65 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
| 66 | + * |
|
| 67 | + * @uses api_request() |
|
| 68 | + * |
|
| 69 | + * @param array $_transient_data Update array build by WordPress. |
|
| 70 | + * @return array Modified update array with custom plugin data. |
|
| 71 | + */ |
|
| 72 | + function check_update( $_transient_data ) { |
|
| 73 | 73 | |
| 74 | - global $pagenow; |
|
| 74 | + global $pagenow; |
|
| 75 | 75 | |
| 76 | - if( ! is_object( $_transient_data ) ) { |
|
| 77 | - $_transient_data = new stdClass; |
|
| 78 | - } |
|
| 76 | + if( ! is_object( $_transient_data ) ) { |
|
| 77 | + $_transient_data = new stdClass; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
| 81 | - return $_transient_data; |
|
| 82 | - } |
|
| 80 | + if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
| 81 | + return $_transient_data; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
| 84 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
| 85 | 85 | |
| 86 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
| 86 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
| 87 | 87 | |
| 88 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
| 88 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
| 89 | 89 | |
| 90 | - $this->did_check = true; |
|
| 90 | + $this->did_check = true; |
|
| 91 | 91 | |
| 92 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 92 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 93 | 93 | |
| 94 | - $_transient_data->response[ $this->name ] = $version_info; |
|
| 94 | + $_transient_data->response[ $this->name ] = $version_info; |
|
| 95 | 95 | |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - $_transient_data->last_checked = time(); |
|
| 99 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
| 98 | + $_transient_data->last_checked = time(); |
|
| 99 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
| 100 | 100 | |
| 101 | - } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $_transient_data; |
|
| 106 | - } |
|
| 105 | + return $_transient_data; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
| 110 | - * |
|
| 111 | - * @param string $file |
|
| 112 | - * @param array $plugin |
|
| 113 | - */ |
|
| 114 | - public function show_update_notification( $file, $plugin ) { |
|
| 108 | + /** |
|
| 109 | + * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
| 110 | + * |
|
| 111 | + * @param string $file |
|
| 112 | + * @param array $plugin |
|
| 113 | + */ |
|
| 114 | + public function show_update_notification( $file, $plugin ) { |
|
| 115 | 115 | |
| 116 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
| 117 | - return; |
|
| 118 | - } |
|
| 116 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
| 117 | + return; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - if( ! is_multisite() ) { |
|
| 121 | - return; |
|
| 122 | - } |
|
| 120 | + if( ! is_multisite() ) { |
|
| 121 | + return; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - if ( $this->name != $file ) { |
|
| 125 | - return; |
|
| 126 | - } |
|
| 124 | + if ( $this->name != $file ) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - // Remove our filter on the site transient |
|
| 129 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
| 128 | + // Remove our filter on the site transient |
|
| 129 | + remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
| 130 | 130 | |
| 131 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
| 131 | + $update_cache = get_site_transient( 'update_plugins' ); |
|
| 132 | 132 | |
| 133 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
| 133 | + if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
| 134 | 134 | |
| 135 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
| 136 | - $version_info = get_transient( $cache_key ); |
|
| 135 | + $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
| 136 | + $version_info = get_transient( $cache_key ); |
|
| 137 | 137 | |
| 138 | - if( false === $version_info ) { |
|
| 138 | + if( false === $version_info ) { |
|
| 139 | 139 | |
| 140 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
| 140 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
| 141 | 141 | |
| 142 | - set_transient( $cache_key, $version_info, 3600 ); |
|
| 143 | - } |
|
| 142 | + set_transient( $cache_key, $version_info, 3600 ); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | 145 | |
| 146 | - if( ! is_object( $version_info ) ) { |
|
| 147 | - return; |
|
| 148 | - } |
|
| 146 | + if( ! is_object( $version_info ) ) { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 150 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 151 | 151 | |
| 152 | - $update_cache->response[ $this->name ] = $version_info; |
|
| 152 | + $update_cache->response[ $this->name ] = $version_info; |
|
| 153 | 153 | |
| 154 | - } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $update_cache->last_checked = time(); |
|
| 157 | - $update_cache->checked[ $this->name ] = $this->version; |
|
| 156 | + $update_cache->last_checked = time(); |
|
| 157 | + $update_cache->checked[ $this->name ] = $this->version; |
|
| 158 | 158 | |
| 159 | - set_site_transient( 'update_plugins', $update_cache ); |
|
| 159 | + set_site_transient( 'update_plugins', $update_cache ); |
|
| 160 | 160 | |
| 161 | - } else { |
|
| 161 | + } else { |
|
| 162 | 162 | |
| 163 | - $version_info = $update_cache->response[ $this->name ]; |
|
| 163 | + $version_info = $update_cache->response[ $this->name ]; |
|
| 164 | 164 | |
| 165 | - } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - // Restore our filter |
|
| 168 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 167 | + // Restore our filter |
|
| 168 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 169 | 169 | |
| 170 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 170 | + if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 171 | 171 | |
| 172 | - // build a plugin list row, with update notification |
|
| 173 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 174 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
| 172 | + // build a plugin list row, with update notification |
|
| 173 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 174 | + echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
| 175 | 175 | |
| 176 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
| 176 | + $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
| 177 | 177 | |
| 178 | - if ( empty( $version_info->download_link ) ) { |
|
| 179 | - printf( |
|
| 178 | + if ( empty( $version_info->download_link ) ) { |
|
| 179 | + printf( |
|
| 180 | 180 | /* translators: 1: name 2: changelog URL 3: version */ |
| 181 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
| 182 | - esc_html( $version_info->name ), |
|
| 183 | - esc_url( $changelog_link ), |
|
| 184 | - esc_html( $version_info->new_version ) |
|
| 185 | - ); |
|
| 186 | - } else { |
|
| 187 | - printf( |
|
| 181 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
| 182 | + esc_html( $version_info->name ), |
|
| 183 | + esc_url( $changelog_link ), |
|
| 184 | + esc_html( $version_info->new_version ) |
|
| 185 | + ); |
|
| 186 | + } else { |
|
| 187 | + printf( |
|
| 188 | 188 | /* translators: 1: name 2: changelog URL 3: version 4: update URL */ |
| 189 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
| 190 | - esc_html( $version_info->name ), |
|
| 191 | - esc_url( $changelog_link ), |
|
| 192 | - esc_html( $version_info->new_version ), |
|
| 193 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
| 194 | - ); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - echo '</div></td></tr>'; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Updates information on the "View version x.x details" page with custom data. |
|
| 204 | - * |
|
| 205 | - * @uses api_request() |
|
| 206 | - * |
|
| 207 | - * @param mixed $_data |
|
| 208 | - * @param string $_action |
|
| 209 | - * @param object $_args |
|
| 210 | - * @return object $_data |
|
| 211 | - */ |
|
| 212 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - if ( $_action != 'plugin_information' ) { |
|
| 216 | - |
|
| 217 | - return $_data; |
|
| 218 | - |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
| 222 | - |
|
| 223 | - return $_data; |
|
| 224 | - |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $to_send = array( |
|
| 228 | - 'slug' => $this->slug, |
|
| 229 | - 'is_ssl' => is_ssl(), |
|
| 230 | - 'fields' => array( |
|
| 231 | - 'banners' => false, // These will be supported soon hopefully |
|
| 232 | - 'reviews' => false |
|
| 233 | - ) |
|
| 234 | - ); |
|
| 235 | - |
|
| 236 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
| 237 | - |
|
| 238 | - if ( false !== $api_response ) { |
|
| 239 | - $_data = $api_response; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - return $_data; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * Disable SSL verification in order to prevent download update failures |
|
| 248 | - * |
|
| 249 | - * @param array $args |
|
| 250 | - * @param string $url |
|
| 251 | - * @return object $array |
|
| 252 | - */ |
|
| 253 | - function http_request_args( $args, $url ) { |
|
| 254 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
| 255 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
| 256 | - $args['sslverify'] = false; |
|
| 257 | - } |
|
| 258 | - return $args; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
| 263 | - * |
|
| 264 | - * @uses get_bloginfo() |
|
| 265 | - * @uses wp_remote_post() |
|
| 266 | - * @uses is_wp_error() |
|
| 267 | - * |
|
| 268 | - * @param string $_action The requested action. |
|
| 269 | - * @param array $_data Parameters for the API action. |
|
| 270 | - * @return false||object |
|
| 271 | - */ |
|
| 272 | - private function api_request( $_action, $_data ) { |
|
| 273 | - |
|
| 274 | - global $wp_version; |
|
| 275 | - |
|
| 276 | - $data = array_merge( $this->api_data, $_data ); |
|
| 277 | - |
|
| 278 | - if ( $data['slug'] != $this->slug ) |
|
| 279 | - return; |
|
| 280 | - |
|
| 281 | - if ( empty( $data['license'] ) ) |
|
| 282 | - return; |
|
| 283 | - |
|
| 284 | - if( $this->api_url == home_url() ) { |
|
| 285 | - return false; // Don't allow a plugin to ping itself |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - $api_params = array( |
|
| 289 | - 'edd_action' => 'get_version', |
|
| 290 | - 'license' => $data['license'], |
|
| 291 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
| 292 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
| 293 | - 'slug' => $data['slug'], |
|
| 294 | - 'author' => $data['author'], |
|
| 295 | - 'url' => home_url() |
|
| 296 | - ); |
|
| 189 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
| 190 | + esc_html( $version_info->name ), |
|
| 191 | + esc_url( $changelog_link ), |
|
| 192 | + esc_html( $version_info->new_version ), |
|
| 193 | + esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
| 194 | + ); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + echo '</div></td></tr>'; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Updates information on the "View version x.x details" page with custom data. |
|
| 204 | + * |
|
| 205 | + * @uses api_request() |
|
| 206 | + * |
|
| 207 | + * @param mixed $_data |
|
| 208 | + * @param string $_action |
|
| 209 | + * @param object $_args |
|
| 210 | + * @return object $_data |
|
| 211 | + */ |
|
| 212 | + function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + if ( $_action != 'plugin_information' ) { |
|
| 216 | + |
|
| 217 | + return $_data; |
|
| 218 | + |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
| 222 | + |
|
| 223 | + return $_data; |
|
| 224 | + |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $to_send = array( |
|
| 228 | + 'slug' => $this->slug, |
|
| 229 | + 'is_ssl' => is_ssl(), |
|
| 230 | + 'fields' => array( |
|
| 231 | + 'banners' => false, // These will be supported soon hopefully |
|
| 232 | + 'reviews' => false |
|
| 233 | + ) |
|
| 234 | + ); |
|
| 235 | + |
|
| 236 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
| 237 | + |
|
| 238 | + if ( false !== $api_response ) { |
|
| 239 | + $_data = $api_response; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + return $_data; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Disable SSL verification in order to prevent download update failures |
|
| 248 | + * |
|
| 249 | + * @param array $args |
|
| 250 | + * @param string $url |
|
| 251 | + * @return object $array |
|
| 252 | + */ |
|
| 253 | + function http_request_args( $args, $url ) { |
|
| 254 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
| 255 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
| 256 | + $args['sslverify'] = false; |
|
| 257 | + } |
|
| 258 | + return $args; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
| 263 | + * |
|
| 264 | + * @uses get_bloginfo() |
|
| 265 | + * @uses wp_remote_post() |
|
| 266 | + * @uses is_wp_error() |
|
| 267 | + * |
|
| 268 | + * @param string $_action The requested action. |
|
| 269 | + * @param array $_data Parameters for the API action. |
|
| 270 | + * @return false||object |
|
| 271 | + */ |
|
| 272 | + private function api_request( $_action, $_data ) { |
|
| 273 | + |
|
| 274 | + global $wp_version; |
|
| 275 | + |
|
| 276 | + $data = array_merge( $this->api_data, $_data ); |
|
| 277 | + |
|
| 278 | + if ( $data['slug'] != $this->slug ) |
|
| 279 | + return; |
|
| 280 | + |
|
| 281 | + if ( empty( $data['license'] ) ) |
|
| 282 | + return; |
|
| 283 | + |
|
| 284 | + if( $this->api_url == home_url() ) { |
|
| 285 | + return false; // Don't allow a plugin to ping itself |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + $api_params = array( |
|
| 289 | + 'edd_action' => 'get_version', |
|
| 290 | + 'license' => $data['license'], |
|
| 291 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
| 292 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
| 293 | + 'slug' => $data['slug'], |
|
| 294 | + 'author' => $data['author'], |
|
| 295 | + 'url' => home_url() |
|
| 296 | + ); |
|
| 297 | 297 | |
| 298 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
| 298 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
| 299 | 299 | |
| 300 | - if ( ! is_wp_error( $request ) ) { |
|
| 301 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
| 302 | - } |
|
| 300 | + if ( ! is_wp_error( $request ) ) { |
|
| 301 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - if ( $request && isset( $request->sections ) ) { |
|
| 305 | - $request->sections = maybe_unserialize( $request->sections ); |
|
| 306 | - } else { |
|
| 307 | - $request = false; |
|
| 308 | - } |
|
| 304 | + if ( $request && isset( $request->sections ) ) { |
|
| 305 | + $request->sections = maybe_unserialize( $request->sections ); |
|
| 306 | + } else { |
|
| 307 | + $request = false; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - return $request; |
|
| 311 | - } |
|
| 310 | + return $request; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - public function show_changelog() { |
|
| 313 | + public function show_changelog() { |
|
| 314 | 314 | |
| 315 | 315 | |
| 316 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
| 317 | - return; |
|
| 318 | - } |
|
| 316 | + if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
| 317 | + return; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
| 321 | - return; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - if( empty( $_REQUEST['slug'] ) ) { |
|
| 325 | - return; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
| 329 | - wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'edd' ), esc_html__( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
| 333 | - |
|
| 334 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
| 335 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - exit; |
|
| 340 | - } |
|
| 320 | + if( empty( $_REQUEST['plugin'] ) ) { |
|
| 321 | + return; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + if( empty( $_REQUEST['slug'] ) ) { |
|
| 325 | + return; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
| 329 | + wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'edd' ), esc_html__( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
| 333 | + |
|
| 334 | + if( $response && isset( $response->sections['changelog'] ) ) { |
|
| 335 | + echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + exit; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | 342 | } |
@@ -408,30 +408,30 @@ |
||
| 408 | 408 | die( '-2' ); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 412 | - esc_html_e( 'n/a', 'give' ); |
|
| 413 | - } else { |
|
| 414 | - // Payment object. |
|
| 415 | - $payment = new Give_Payment( $payment_id ); |
|
| 416 | - |
|
| 417 | - // Payment meta. |
|
| 418 | - $payment_meta = $payment->get_meta(); |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - // Variable price dropdown options. |
|
| 422 | - $variable_price_dropdown_option = array( |
|
| 423 | - 'id' => $form_id, |
|
| 424 | - 'name' => 'give-variable-price', |
|
| 425 | - 'chosen' => true, |
|
| 426 | - 'show_option_all' => '', |
|
| 427 | - 'selected' => $payment_meta['price_id'], |
|
| 428 | - ); |
|
| 429 | - |
|
| 430 | - // Render variable prices select tag html. |
|
| 431 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - give_die(); |
|
| 411 | + if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 412 | + esc_html_e( 'n/a', 'give' ); |
|
| 413 | + } else { |
|
| 414 | + // Payment object. |
|
| 415 | + $payment = new Give_Payment( $payment_id ); |
|
| 416 | + |
|
| 417 | + // Payment meta. |
|
| 418 | + $payment_meta = $payment->get_meta(); |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + // Variable price dropdown options. |
|
| 422 | + $variable_price_dropdown_option = array( |
|
| 423 | + 'id' => $form_id, |
|
| 424 | + 'name' => 'give-variable-price', |
|
| 425 | + 'chosen' => true, |
|
| 426 | + 'show_option_all' => '', |
|
| 427 | + 'selected' => $payment_meta['price_id'], |
|
| 428 | + ); |
|
| 429 | + |
|
| 430 | + // Render variable prices select tag html. |
|
| 431 | + give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + give_die(); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |