@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | - $this->shortcode['title'] = esc_html__( 'Donation Form', 'give' ); |
|
| 28 | - $this->shortcode['label'] = esc_html__( 'Donation Form', 'give' ); |
|
| 27 | + $this->shortcode['title'] = esc_html__('Donation Form', 'give'); |
|
| 28 | + $this->shortcode['label'] = esc_html__('Donation Form', 'give'); |
|
| 29 | 29 | |
| 30 | - parent::__construct( 'give_form' ); |
|
| 30 | + parent::__construct('give_form'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $create_form_link = sprintf( |
| 41 | 41 | /* translators: %s: create new form URL */ |
| 42 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
| 43 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
| 42 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
| 43 | + admin_url('post-new.php?post_type=give_forms') |
|
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | return array( |
@@ -50,68 +50,68 @@ discard block |
||
| 50 | 50 | 'post_type' => 'give_forms', |
| 51 | 51 | ), |
| 52 | 52 | 'name' => 'id', |
| 53 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
| 54 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
| 53 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
| 54 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
| 55 | 55 | 'required' => array( |
| 56 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
| 57 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
| 56 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
| 57 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
| 58 | 58 | ), |
| 59 | 59 | ), |
| 60 | 60 | array( |
| 61 | 61 | 'type' => 'container', |
| 62 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
| 62 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
| 63 | 63 | ), |
| 64 | 64 | array( |
| 65 | 65 | 'type' => 'listbox', |
| 66 | 66 | 'name' => 'show_title', |
| 67 | - 'label' => esc_attr__( 'Show Title', 'give' ), |
|
| 68 | - 'tooltip' => esc_attr__( 'Do you want to display the form title?', 'give' ), |
|
| 67 | + 'label' => esc_attr__('Show Title', 'give'), |
|
| 68 | + 'tooltip' => esc_attr__('Do you want to display the form title?', 'give'), |
|
| 69 | 69 | 'options' => array( |
| 70 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 71 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 70 | + 'true' => esc_html__('Show', 'give'), |
|
| 71 | + 'false' => esc_html__('Hide', 'give'), |
|
| 72 | 72 | ), |
| 73 | 73 | ), |
| 74 | 74 | array( |
| 75 | 75 | 'type' => 'listbox', |
| 76 | 76 | 'name' => 'show_goal', |
| 77 | - 'label' => esc_attr__( 'Show Goal', 'give' ), |
|
| 78 | - 'tooltip' => esc_attr__( 'Do you want to display the donation goal?', 'give' ), |
|
| 77 | + 'label' => esc_attr__('Show Goal', 'give'), |
|
| 78 | + 'tooltip' => esc_attr__('Do you want to display the donation goal?', 'give'), |
|
| 79 | 79 | 'options' => array( |
| 80 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 81 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 80 | + 'true' => esc_html__('Show', 'give'), |
|
| 81 | + 'false' => esc_html__('Hide', 'give'), |
|
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | array( |
| 85 | 85 | 'type' => 'listbox', |
| 86 | 86 | 'name' => 'show_content', |
| 87 | 87 | 'minWidth' => 240, |
| 88 | - 'label' => esc_attr__( 'Display Content', 'give' ), |
|
| 89 | - 'tooltip' => esc_attr__( 'Do you want to display the form content?', 'give' ), |
|
| 88 | + 'label' => esc_attr__('Display Content', 'give'), |
|
| 89 | + 'tooltip' => esc_attr__('Do you want to display the form content?', 'give'), |
|
| 90 | 90 | 'options' => array( |
| 91 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
| 92 | - 'above' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
| 93 | - 'below' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
| 91 | + 'none' => esc_html__('No Content', 'give'), |
|
| 92 | + 'above' => esc_html__('Display content ABOVE the fields', 'give'), |
|
| 93 | + 'below' => esc_html__('Display content BELOW the fields', 'give'), |
|
| 94 | 94 | ), |
| 95 | 95 | ), |
| 96 | 96 | array( |
| 97 | 97 | 'type' => 'listbox', |
| 98 | 98 | 'name' => 'display_style', |
| 99 | 99 | 'classes' => 'give-display-style', |
| 100 | - 'label' => esc_attr__( 'Display Options', 'give' ), |
|
| 101 | - 'tooltip' => esc_attr__( 'How would you like to display donation information?', 'give' ), |
|
| 100 | + 'label' => esc_attr__('Display Options', 'give'), |
|
| 101 | + 'tooltip' => esc_attr__('How would you like to display donation information?', 'give'), |
|
| 102 | 102 | 'options' => array( |
| 103 | - 'onpage' => esc_html__( 'All Fields', 'give' ), |
|
| 104 | - 'modal' => esc_html__( 'Modal', 'give' ), |
|
| 105 | - 'reveal' => esc_html__( 'Reveal', 'give' ), |
|
| 106 | - 'button' => esc_html__( 'Button', 'give' ), |
|
| 103 | + 'onpage' => esc_html__('All Fields', 'give'), |
|
| 104 | + 'modal' => esc_html__('Modal', 'give'), |
|
| 105 | + 'reveal' => esc_html__('Reveal', 'give'), |
|
| 106 | + 'button' => esc_html__('Button', 'give'), |
|
| 107 | 107 | ), |
| 108 | 108 | ), |
| 109 | 109 | array( |
| 110 | 110 | 'type' => 'textbox', |
| 111 | 111 | 'classes' => 'give-hidden give-continue-button-title', |
| 112 | 112 | 'name' => 'continue_button_title', |
| 113 | - 'label' => esc_attr__( 'Button Text', 'give' ), |
|
| 114 | - 'tooltip' => esc_attr__( 'The button label for displaying the additional payment fields.', 'give' ), |
|
| 113 | + 'label' => esc_attr__('Button Text', 'give'), |
|
| 114 | + 'tooltip' => esc_attr__('The button label for displaying the additional payment fields.', 'give'), |
|
| 115 | 115 | ), |
| 116 | 116 | ); |
| 117 | 117 | } |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_API' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_API')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_API. |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'api'; |
| 46 | - $this->label = esc_html__( 'API', 'give' ); |
|
| 46 | + $this->label = esc_html__('API', 'give'); |
|
| 47 | 47 | |
| 48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
| 49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
| 49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | * @param array $pages Lst of pages. |
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | - public function add_settings_page( $pages ) { |
|
| 60 | - $pages[ $this->id ] = $this->label; |
|
| 59 | + public function add_settings_page($pages) { |
|
| 60 | + $pages[$this->id] = $this->label; |
|
| 61 | 61 | |
| 62 | 62 | return $pages; |
| 63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $GLOBALS['give_hide_save_button'] = true; |
| 74 | 74 | |
| 75 | 75 | // Get settings. |
| 76 | - $settings = apply_filters( 'give_settings_api', array( |
|
| 76 | + $settings = apply_filters('give_settings_api', array( |
|
| 77 | 77 | array( |
| 78 | 78 | 'id' => 'give_tools_api', |
| 79 | 79 | 'type' => 'title', |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | ), |
| 82 | 82 | array( |
| 83 | 83 | 'id' => 'api', |
| 84 | - 'name' => esc_html__( 'API', 'give' ), |
|
| 84 | + 'name' => esc_html__('API', 'give'), |
|
| 85 | 85 | 'type' => 'api', |
| 86 | 86 | ), |
| 87 | 87 | array( |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @since 1.8 |
| 98 | 98 | * @param array $settings |
| 99 | 99 | */ |
| 100 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 100 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 101 | 101 | |
| 102 | 102 | // Output. |
| 103 | 103 | return $settings; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | public function output() { |
| 113 | 113 | $settings = $this->get_settings(); |
| 114 | 114 | |
| 115 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 115 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Data' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Data')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Data. |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'data'; |
| 46 | - $this->label = esc_html__( 'Data', 'give' ); |
|
| 46 | + $this->label = esc_html__('Data', 'give'); |
|
| 47 | 47 | |
| 48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
| 49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
| 49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
| 50 | 50 | |
| 51 | 51 | // Do not use main form for this tab. |
| 52 | - if( give_get_current_setting_tab() === $this->id ) { |
|
| 53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
| 54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
| 52 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
| 54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | * @param array $pages Lst of pages. |
| 63 | 63 | * @return array |
| 64 | 64 | */ |
| 65 | - public function add_settings_page( $pages ) { |
|
| 66 | - $pages[ $this->id ] = $this->label; |
|
| 65 | + public function add_settings_page($pages) { |
|
| 66 | + $pages[$this->id] = $this->label; |
|
| 67 | 67 | |
| 68 | 68 | return $pages; |
| 69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $GLOBALS['give_hide_save_button'] = true; |
| 80 | 80 | |
| 81 | 81 | // Get settings. |
| 82 | - $settings = apply_filters( 'give_settings_data', array( |
|
| 82 | + $settings = apply_filters('give_settings_data', array( |
|
| 83 | 83 | array( |
| 84 | 84 | 'id' => 'give_tools_tools', |
| 85 | 85 | 'type' => 'title', |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | ), |
| 88 | 88 | array( |
| 89 | 89 | 'id' => 'api', |
| 90 | - 'name' => esc_html__( 'Tools', 'give' ), |
|
| 90 | + 'name' => esc_html__('Tools', 'give'), |
|
| 91 | 91 | 'type' => 'data', |
| 92 | 92 | ), |
| 93 | 93 | array( |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @since 1.8 |
| 104 | 104 | * @param array $settings |
| 105 | 105 | */ |
| 106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 107 | 107 | |
| 108 | 108 | // Output. |
| 109 | 109 | return $settings; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function output() { |
| 119 | 119 | $settings = $this->get_settings(); |
| 120 | 120 | |
| 121 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 121 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -205,7 +205,7 @@ |
||
| 205 | 205 | * |
| 206 | 206 | * @param bool $force If set to true then all cached values will be delete instead of only expired |
| 207 | 207 | * |
| 208 | - * @return bool |
|
| 208 | + * @return false|null |
|
| 209 | 209 | */ |
| 210 | 210 | public static function delete_all_expired( $force = false ) { |
| 211 | 211 | global $wpdb; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return static |
| 44 | 44 | */ |
| 45 | 45 | public static function get_instance() { |
| 46 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
| 46 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
| 47 | 47 | self::$instance = new Give_Cache(); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setup_hooks() { |
| 60 | 60 | // weekly delete all expired cache. |
| 61 | - add_action( 'give_weekly_scheduled_events', array( $this, 'delete_all_expired' ) ); |
|
| 61 | + add_action('give_weekly_scheduled_events', array($this, 'delete_all_expired')); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | * @return string |
| 73 | 73 | */ |
| 74 | 74 | |
| 75 | - public static function get_key( $action, $query_args = null ) { |
|
| 75 | + public static function get_key($action, $query_args = null) { |
|
| 76 | 76 | $cache_key = "give_cache_{$action}"; |
| 77 | 77 | |
| 78 | 78 | // Bailout. |
| 79 | - if ( ! empty( $query_args ) ) { |
|
| 80 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
| 79 | + if ( ! empty($query_args)) { |
|
| 80 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | return $cache_key; |
@@ -95,26 +95,26 @@ discard block |
||
| 95 | 95 | * @return mixed |
| 96 | 96 | */ |
| 97 | 97 | |
| 98 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
| 99 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
| 100 | - if ( ! $custom_key ) { |
|
| 101 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
| 98 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
| 99 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
| 100 | + if ( ! $custom_key) { |
|
| 101 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
| 104 | + $cache_key = self::get_key($cache_key, $query_args); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $option = get_option( $cache_key ); |
|
| 107 | + $option = get_option($cache_key); |
|
| 108 | 108 | |
| 109 | 109 | // Backward compatibility (<1.8.7). |
| 110 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
| 110 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
| 111 | 111 | return $option; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // Get current time. |
| 115 | - $current_time = current_time( 'timestamp', 1 ); |
|
| 115 | + $current_time = current_time('timestamp', 1); |
|
| 116 | 116 | |
| 117 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
| 117 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
| 118 | 118 | $option = $option['data']; |
| 119 | 119 | } else { |
| 120 | 120 | $option = false; |
@@ -137,23 +137,23 @@ discard block |
||
| 137 | 137 | * @return mixed |
| 138 | 138 | */ |
| 139 | 139 | |
| 140 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
| 141 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
| 142 | - if ( ! $custom_key ) { |
|
| 143 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
| 140 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
| 141 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
| 142 | + if ( ! $custom_key) { |
|
| 143 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
| 146 | + $cache_key = self::get_key($cache_key, $query_args); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $option_value = array( |
| 150 | 150 | 'data' => $data, |
| 151 | - 'expiration' => ! is_null( $expiration ) |
|
| 152 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
| 151 | + 'expiration' => ! is_null($expiration) |
|
| 152 | + ? ($expiration + current_time('timestamp', 1)) |
|
| 153 | 153 | : null, |
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
| 156 | + $result = update_option($cache_key, $option_value, 'no'); |
|
| 157 | 157 | |
| 158 | 158 | return $result; |
| 159 | 159 | } |
@@ -168,27 +168,27 @@ discard block |
||
| 168 | 168 | * @return bool|WP_Error |
| 169 | 169 | */ |
| 170 | 170 | |
| 171 | - public static function delete( $cache_keys ) { |
|
| 171 | + public static function delete($cache_keys) { |
|
| 172 | 172 | $result = true; |
| 173 | 173 | $invalid_keys = array(); |
| 174 | 174 | |
| 175 | - if ( ! empty( $cache_keys ) ) { |
|
| 176 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
| 175 | + if ( ! empty($cache_keys)) { |
|
| 176 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
| 177 | 177 | |
| 178 | - foreach ( $cache_keys as $cache_key ) { |
|
| 179 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
| 178 | + foreach ($cache_keys as $cache_key) { |
|
| 179 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
| 180 | 180 | $invalid_keys[] = $cache_key; |
| 181 | 181 | $result = false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - delete_option( $cache_key ); |
|
| 184 | + delete_option($cache_key); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if( ! $result ) { |
|
| 188 | + if ( ! $result) { |
|
| 189 | 189 | $result = new WP_Error( |
| 190 | 190 | 'give_invalid_cache_key', |
| 191 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
| 191 | + __('Cache key format should be give_cache_*', 'give'), |
|
| 192 | 192 | $invalid_keys |
| 193 | 193 | ); |
| 194 | 194 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return bool |
| 209 | 209 | */ |
| 210 | - public static function delete_all_expired( $force = false ) { |
|
| 210 | + public static function delete_all_expired($force = false) { |
|
| 211 | 211 | global $wpdb; |
| 212 | 212 | $options = $wpdb->get_results( |
| 213 | 213 | $wpdb->prepare( |
@@ -221,30 +221,30 @@ discard block |
||
| 221 | 221 | ); |
| 222 | 222 | |
| 223 | 223 | // Bailout. |
| 224 | - if ( empty( $options ) ) { |
|
| 224 | + if (empty($options)) { |
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $current_time = current_time( 'timestamp', 1 ); |
|
| 228 | + $current_time = current_time('timestamp', 1); |
|
| 229 | 229 | |
| 230 | 230 | // Delete log cache. |
| 231 | - foreach ( $options as $option ) { |
|
| 232 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
| 231 | + foreach ($options as $option) { |
|
| 232 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
| 233 | 233 | |
| 234 | 234 | if ( |
| 235 | 235 | ( |
| 236 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
| 237 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
| 238 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
| 239 | - || empty( $option['option_value']['expiration'] ) |
|
| 240 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
| 236 | + ! self::is_valid_cache_key($option['option_name']) |
|
| 237 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
| 238 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
| 239 | + || empty($option['option_value']['expiration']) |
|
| 240 | + || ($current_time < $option['option_value']['expiration']) |
|
| 241 | 241 | ) |
| 242 | 242 | && ! $force |
| 243 | 243 | ) { |
| 244 | 244 | continue; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - self::delete( $option['option_name'] ); |
|
| 247 | + self::delete($option['option_name']); |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | |
@@ -260,16 +260,16 @@ discard block |
||
| 260 | 260 | * |
| 261 | 261 | * @return array |
| 262 | 262 | */ |
| 263 | - public static function get_options_like( $option_name, $fields = false ) { |
|
| 263 | + public static function get_options_like($option_name, $fields = false) { |
|
| 264 | 264 | global $wpdb; |
| 265 | 265 | |
| 266 | - if ( empty( $option_name ) ) { |
|
| 266 | + if (empty($option_name)) { |
|
| 267 | 267 | return array(); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
| 271 | 271 | |
| 272 | - if ( $fields ) { |
|
| 272 | + if ($fields) { |
|
| 273 | 273 | $options = $wpdb->get_results( |
| 274 | 274 | $wpdb->prepare( |
| 275 | 275 | "SELECT {$field_names } |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | ); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if ( ! empty( $options ) && $fields ) { |
|
| 297 | - foreach ( $options as $index => $option ) { |
|
| 298 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
| 299 | - $options[ $index ] = $option; |
|
| 296 | + if ( ! empty($options) && $fields) { |
|
| 297 | + foreach ($options as $index => $option) { |
|
| 298 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
| 299 | + $options[$index] = $option; |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
@@ -313,8 +313,8 @@ discard block |
||
| 313 | 313 | * |
| 314 | 314 | * @return bool|int |
| 315 | 315 | */ |
| 316 | - public static function is_valid_cache_key( $cache_key ) { |
|
| 317 | - return ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
| 316 | + public static function is_valid_cache_key($cache_key) { |
|
| 317 | + return (false !== strpos($cache_key, 'give_cache_')); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -10,61 +10,61 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Load Give file. |
| 18 | -include_once( 'give.php' ); |
|
| 18 | +include_once('give.php'); |
|
| 19 | 19 | |
| 20 | 20 | global $wpdb, $wp_roles; |
| 21 | 21 | |
| 22 | 22 | |
| 23 | -if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) { |
|
| 23 | +if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) { |
|
| 24 | 24 | |
| 25 | 25 | // Delete All the Custom Post Types. |
| 26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' ); |
|
| 27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
| 28 | - foreach ( $give_post_types as $post_type ) { |
|
| 26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type'); |
|
| 27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
| 28 | + foreach ($give_post_types as $post_type) { |
|
| 29 | 29 | |
| 30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
| 31 | - $items = get_posts( array( |
|
| 30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
| 31 | + $items = get_posts(array( |
|
| 32 | 32 | 'post_type' => $post_type, |
| 33 | 33 | 'post_status' => 'any', |
| 34 | - 'numberposts' => - 1, |
|
| 34 | + 'numberposts' => -1, |
|
| 35 | 35 | 'fields' => 'ids', |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - if ( $items ) { |
|
| 39 | - foreach ( $items as $item ) { |
|
| 40 | - wp_delete_post( $item, true ); |
|
| 38 | + if ($items) { |
|
| 39 | + foreach ($items as $item) { |
|
| 40 | + wp_delete_post($item, true); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Delete All the Terms & Taxonomies. |
| 46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
| 46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
| 47 | 47 | |
| 48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
| 48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
| 49 | 49 | |
| 50 | 50 | // Delete Terms. |
| 51 | - if ( $terms ) { |
|
| 52 | - foreach ( $terms as $term ) { |
|
| 53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
| 54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
| 51 | + if ($terms) { |
|
| 52 | + foreach ($terms as $term) { |
|
| 53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
| 54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Delete Taxonomies. |
| 59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
| 59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Delete the Plugin Pages. |
| 63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
| 64 | - foreach ( $give_created_pages as $p ) { |
|
| 65 | - $page = give_get_option( $p, false ); |
|
| 66 | - if ( $page ) { |
|
| 67 | - wp_delete_post( $page, true ); |
|
| 63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
| 64 | + foreach ($give_created_pages as $p) { |
|
| 65 | + $page = give_get_option($p, false); |
|
| 66 | + if ($page) { |
|
| 67 | + wp_delete_post($page, true); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,20 +72,20 @@ discard block |
||
| 72 | 72 | Give()->roles->remove_caps(); |
| 73 | 73 | |
| 74 | 74 | // Delete the Roles. |
| 75 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
| 76 | - foreach ( $give_roles as $role ) { |
|
| 77 | - remove_role( $role ); |
|
| 75 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
| 76 | + foreach ($give_roles as $role) { |
|
| 77 | + remove_role($role); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Remove all database tables. |
| 81 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
| 82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
| 83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
| 81 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
| 82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
| 83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
| 84 | 84 | |
| 85 | 85 | // Cleanup Cron Events. |
| 86 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
| 87 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
| 88 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
| 86 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
| 87 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
| 88 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
| 89 | 89 | |
| 90 | 90 | // Get all options. |
| 91 | 91 | $give_option_names = $wpdb->get_col( |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | ) |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - if ( ! empty( $give_option_names ) ) { |
|
| 98 | + if ( ! empty($give_option_names)) { |
|
| 99 | 99 | // Convert option name to transient or option name. |
| 100 | 100 | $new_give_option_names = array(); |
| 101 | 101 | |
| 102 | 102 | // Delete all the Plugin Options. |
| 103 | - foreach ( $give_option_names as $option ) { |
|
| 104 | - if ( false !== strpos( $option, 'give_cache' ) ) { |
|
| 105 | - Give_Cache::delete( $option ); |
|
| 103 | + foreach ($give_option_names as $option) { |
|
| 104 | + if (false !== strpos($option, 'give_cache')) { |
|
| 105 | + Give_Cache::delete($option); |
|
| 106 | 106 | } else { |
| 107 | - delete_option( $option ); |
|
| 107 | + delete_option($option); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | ob_start(); ?> |
| 27 | 27 | <div class="wrap" id="give-add-ons"> |
| 28 | 28 | <h1><?php echo get_admin_page_title(); ?> |
| 29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
|
| 29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?> |
|
| 30 | 30 | <span class="dashicons dashicons-external"></span></a> |
| 31 | 31 | </h1> |
| 32 | 32 | |
| 33 | - <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
| 33 | + <p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
| 34 | 34 | <?php echo give_add_ons_get_feed(); ?> |
| 35 | 35 | </div> |
| 36 | 36 | <?php |
@@ -48,20 +48,20 @@ discard block |
||
| 48 | 48 | function give_add_ons_get_feed() { |
| 49 | 49 | |
| 50 | 50 | $addons_debug = false; //set to true to debug |
| 51 | - $cache = Give_Cache::get( 'give_add_ons_feed', true ); |
|
| 51 | + $cache = Give_Cache::get('give_add_ons_feed', true); |
|
| 52 | 52 | |
| 53 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
| 54 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
| 53 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
| 54 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
| 55 | 55 | |
| 56 | - if ( ! is_wp_error( $feed ) ) { |
|
| 57 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
| 58 | - $cache = wp_remote_retrieve_body( $feed ); |
|
| 59 | - Give_Cache::set( 'give_add_ons_feed', $cache, HOUR_IN_SECONDS, true ); |
|
| 56 | + if ( ! is_wp_error($feed)) { |
|
| 57 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
| 58 | + $cache = wp_remote_retrieve_body($feed); |
|
| 59 | + Give_Cache::set('give_add_ons_feed', $cache, HOUR_IN_SECONDS, true); |
|
| 60 | 60 | } |
| 61 | 61 | } else { |
| 62 | 62 | $cache = sprintf( |
| 63 | 63 | '<div class="error"><p>%s</p></div>', |
| 64 | - esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) |
|
| 64 | + esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give') |
|
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,19 +23,19 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array An array of updated action links. |
| 25 | 25 | */ |
| 26 | -function give_plugin_action_links( $actions ) { |
|
| 26 | +function give_plugin_action_links($actions) { |
|
| 27 | 27 | $new_actions = array( |
| 28 | 28 | 'settings' => sprintf( |
| 29 | 29 | '<a href="%1$s">%2$s</a>', |
| 30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
| 31 | - __( 'Settings', 'give' ) |
|
| 30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
| 31 | + __('Settings', 'give') |
|
| 32 | 32 | ), |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - return array_merge( $new_actions, $actions ); |
|
| 35 | + return array_merge($new_actions, $actions); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
| 38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -48,35 +48,35 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
| 52 | - if ( $plugin_file != GIVE_PLUGIN_BASENAME ) { |
|
| 51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
| 52 | + if ($plugin_file != GIVE_PLUGIN_BASENAME) { |
|
| 53 | 53 | return $plugin_meta; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $new_meta_links = array( |
| 57 | 57 | sprintf( |
| 58 | 58 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 59 | - esc_url( add_query_arg( array( |
|
| 59 | + esc_url(add_query_arg(array( |
|
| 60 | 60 | 'utm_source' => 'plugins-page', |
| 61 | 61 | 'utm_medium' => 'plugin-row', |
| 62 | 62 | 'utm_campaign' => 'admin', |
| 63 | - ), 'https://givewp.com/documentation/' ) |
|
| 63 | + ), 'https://givewp.com/documentation/') |
|
| 64 | 64 | ), |
| 65 | - __( 'Documentation', 'give' ) |
|
| 65 | + __('Documentation', 'give') |
|
| 66 | 66 | ), |
| 67 | 67 | sprintf( |
| 68 | 68 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 69 | - esc_url( add_query_arg( array( |
|
| 69 | + esc_url(add_query_arg(array( |
|
| 70 | 70 | 'utm_source' => 'plugins-page', |
| 71 | 71 | 'utm_medium' => 'plugin-row', |
| 72 | 72 | 'utm_campaign' => 'admin', |
| 73 | - ), 'https://givewp.com/addons/' ) |
|
| 73 | + ), 'https://givewp.com/addons/') |
|
| 74 | 74 | ), |
| 75 | - __( 'Add-ons', 'give' ) |
|
| 75 | + __('Add-ons', 'give') |
|
| 76 | 76 | ), |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
| 79 | + return array_merge($plugin_meta, $new_meta_links); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
| 82 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
|
@@ -733,9 +733,9 @@ |
||
| 733 | 733 | <td class="give-docs-link" colspan="2"> |
| 734 | 734 | <?php |
| 735 | 735 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
| 736 | - . '" target="_blank">' |
|
| 737 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 738 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 736 | + . '" target="_blank">' |
|
| 737 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 738 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 739 | 739 | ?> |
| 740 | 740 | </td> |
| 741 | 741 | </tr><?php |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param array $settings Array of settings class object. |
| 74 | 74 | */ |
| 75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
| 75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
| 76 | 76 | |
| 77 | 77 | return self::$settings; |
| 78 | 78 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | public static function save() { |
| 87 | 87 | $current_tab = give_get_current_setting_tab(); |
| 88 | 88 | |
| 89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
| 90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
| 89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
| 90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
| 91 | 91 | die(); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 1.8 |
| 102 | 102 | */ |
| 103 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
| 103 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
| 104 | 104 | |
| 105 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
| 105 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Trigger Action. |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @since 1.8 |
| 115 | 115 | */ |
| 116 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
| 116 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return void |
| 128 | 128 | */ |
| 129 | - public static function add_message( $code, $message ) { |
|
| 130 | - self::$messages[ $code ] = $message; |
|
| 129 | + public static function add_message($code, $message) { |
|
| 130 | + self::$messages[$code] = $message; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | - public static function add_error( $code, $message ) { |
|
| 144 | - self::$errors[ $code ] = $message; |
|
| 143 | + public static function add_error($code, $message) { |
|
| 144 | + self::$errors[$code] = $message; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -154,18 +154,18 @@ discard block |
||
| 154 | 154 | $notice_html = ''; |
| 155 | 155 | $classes = 'give-notice settings-error notice is-dismissible'; |
| 156 | 156 | |
| 157 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
| 158 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
| 157 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
| 158 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
| 159 | 159 | |
| 160 | - if ( 0 < count( self::$errors ) ) { |
|
| 161 | - foreach ( self::$errors as $code => $message ) { |
|
| 162 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
| 160 | + if (0 < count(self::$errors)) { |
|
| 161 | + foreach (self::$errors as $code => $message) { |
|
| 162 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( 0 < count( self::$messages ) ) { |
|
| 167 | - foreach ( self::$messages as $code => $message ) { |
|
| 168 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
| 166 | + if (0 < count(self::$messages)) { |
|
| 167 | + foreach (self::$messages as $code => $message) { |
|
| 168 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | self::$setting_filter_prefix = give_get_current_setting_page(); |
| 186 | 186 | |
| 187 | 187 | // Bailout: Exit if setting page is not defined. |
| 188 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
| 188 | + if (empty(self::$setting_filter_prefix)) { |
|
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @since 1.8 |
| 200 | 200 | */ |
| 201 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
| 201 | + do_action(self::$setting_filter_prefix.'_start'); |
|
| 202 | 202 | |
| 203 | 203 | $current_tab = give_get_current_setting_tab(); |
| 204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | self::get_settings_pages(); |
| 207 | 207 | |
| 208 | 208 | // Save settings if data has been posted. |
| 209 | - if ( ! empty( $_POST ) ) { |
|
| 209 | + if ( ! empty($_POST)) { |
|
| 210 | 210 | self::save(); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @since 1.8 |
| 221 | 221 | */ |
| 222 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
| 222 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
| 223 | 223 | |
| 224 | 224 | include 'views/html-admin-settings.php'; |
| 225 | 225 | |
@@ -237,25 +237,25 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return string|bool |
| 239 | 239 | */ |
| 240 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
| 240 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
| 241 | 241 | // Bailout. |
| 242 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
| 242 | + if (empty($option_name) && empty($field_id)) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
| 246 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
| 247 | 247 | // Get field value if any. |
| 248 | - $option_value = get_option( $option_name ); |
|
| 248 | + $option_value = get_option($option_name); |
|
| 249 | 249 | |
| 250 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
| 251 | - ? $option_value[ $field_id ] |
|
| 250 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
| 251 | + ? $option_value[$field_id] |
|
| 252 | 252 | : $default; |
| 253 | 253 | } else { |
| 254 | 254 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
| 255 | 255 | $option_name = ! $option_name ? $field_id : $option_name; |
| 256 | 256 | |
| 257 | 257 | // Get option value if any. |
| 258 | - $option_value = get_option( $option_name, $default ); |
|
| 258 | + $option_value = get_option($option_name, $default); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | return $option_value; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return void |
| 275 | 275 | */ |
| 276 | - public static function output_fields( $options, $option_name = '' ) { |
|
| 276 | + public static function output_fields($options, $option_name = '') { |
|
| 277 | 277 | $current_tab = give_get_current_setting_tab(); |
| 278 | 278 | |
| 279 | 279 | // Field Default values. |
@@ -286,52 +286,52 @@ discard block |
||
| 286 | 286 | 'table_html' => true, |
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | - foreach ( $options as $value ) { |
|
| 290 | - if ( ! isset( $value['type'] ) ) { |
|
| 289 | + foreach ($options as $value) { |
|
| 290 | + if ( ! isset($value['type'])) { |
|
| 291 | 291 | continue; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // Set title. |
| 295 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
| 295 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
| 296 | 296 | |
| 297 | 297 | // Set default setting. |
| 298 | - $value = wp_parse_args( $value, $defaults ); |
|
| 298 | + $value = wp_parse_args($value, $defaults); |
|
| 299 | 299 | |
| 300 | 300 | // Colorpicker field. |
| 301 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
| 302 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
| 301 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
| 302 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | // Custom attribute handling. |
| 306 | 306 | $custom_attributes = array(); |
| 307 | 307 | |
| 308 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
| 309 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
| 310 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
| 308 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
| 309 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
| 310 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Description handling. |
| 315 | - $description = self::get_field_description( $value ); |
|
| 315 | + $description = self::get_field_description($value); |
|
| 316 | 316 | |
| 317 | 317 | // Switch based on type. |
| 318 | - switch ( $value['type'] ) { |
|
| 318 | + switch ($value['type']) { |
|
| 319 | 319 | |
| 320 | 320 | // Section Titles |
| 321 | 321 | case 'title': |
| 322 | - if ( ! empty( $value['title'] ) ) { |
|
| 323 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
| 322 | + if ( ! empty($value['title'])) { |
|
| 323 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if ( ! empty( $value['desc'] ) ) { |
|
| 327 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
| 326 | + if ( ! empty($value['desc'])) { |
|
| 327 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ( $value['table_html'] ) { |
|
| 331 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
| 330 | + if ($value['table_html']) { |
|
| 331 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if ( ! empty( $value['id'] ) ) { |
|
| 334 | + if ( ! empty($value['id'])) { |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * Trigger Action. |
@@ -340,14 +340,14 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @since 1.8 |
| 342 | 342 | */ |
| 343 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
| 343 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | break; |
| 347 | 347 | |
| 348 | 348 | // Section Ends. |
| 349 | 349 | case 'sectionend': |
| 350 | - if ( ! empty( $value['id'] ) ) { |
|
| 350 | + if ( ! empty($value['id'])) { |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Trigger Action. |
@@ -356,14 +356,14 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @since 1.8 |
| 358 | 358 | */ |
| 359 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
| 359 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - if ( $value['table_html'] ) { |
|
| 362 | + if ($value['table_html']) { |
|
| 363 | 363 | echo '</table>'; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if ( ! empty( $value['id'] ) ) { |
|
| 366 | + if ( ! empty($value['id'])) { |
|
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * Trigger Action. |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @since 1.8 |
| 374 | 374 | */ |
| 375 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
| 375 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | break; |
@@ -385,22 +385,22 @@ discard block |
||
| 385 | 385 | case 'password' : |
| 386 | 386 | |
| 387 | 387 | $type = $value['type']; |
| 388 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 388 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 389 | 389 | |
| 390 | 390 | ?> |
| 391 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 391 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 392 | 392 | <th scope="row" class="titledesc"> |
| 393 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 393 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 394 | 394 | </th> |
| 395 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 395 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 396 | 396 | <input |
| 397 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 398 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 399 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 400 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 401 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
| 402 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 403 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 397 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 398 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 399 | + type="<?php echo esc_attr($type); ?>" |
|
| 400 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 401 | + value="<?php echo esc_attr($option_value); ?>" |
|
| 402 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 403 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 404 | 404 | /> <?php echo $description; ?> |
| 405 | 405 | </td> |
| 406 | 406 | </tr><?php |
@@ -409,23 +409,23 @@ discard block |
||
| 409 | 409 | // Textarea. |
| 410 | 410 | case 'textarea': |
| 411 | 411 | |
| 412 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 412 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 413 | 413 | |
| 414 | 414 | ?> |
| 415 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 415 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 416 | 416 | <th scope="row" class="titledesc"> |
| 417 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 417 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 418 | 418 | </th> |
| 419 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 419 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 420 | 420 | <textarea |
| 421 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 422 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 421 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 422 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 425 | 425 | rows="10" |
| 426 | 426 | cols="60" |
| 427 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 428 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
| 427 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 428 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
| 429 | 429 | <?php echo $description; ?> |
| 430 | 430 | </td> |
| 431 | 431 | </tr><?php |
@@ -435,35 +435,35 @@ discard block |
||
| 435 | 435 | case 'select' : |
| 436 | 436 | case 'multiselect' : |
| 437 | 437 | |
| 438 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 438 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 439 | 439 | |
| 440 | 440 | ?> |
| 441 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 441 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 442 | 442 | <th scope="row" class="titledesc"> |
| 443 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 443 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 444 | 444 | </th> |
| 445 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 445 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 446 | 446 | <select |
| 447 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
| 447 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
| 448 | 448 | echo '[]'; |
| 449 | 449 | } ?>" |
| 450 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 451 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 452 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 453 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 454 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
| 450 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 451 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 452 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 453 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 454 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
| 455 | 455 | > |
| 456 | 456 | |
| 457 | 457 | <?php |
| 458 | - if ( ! empty( $value['options'] ) ) { |
|
| 459 | - foreach ( $value['options'] as $key => $val ) { |
|
| 458 | + if ( ! empty($value['options'])) { |
|
| 459 | + foreach ($value['options'] as $key => $val) { |
|
| 460 | 460 | ?> |
| 461 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
| 461 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
| 462 | 462 | |
| 463 | - if ( is_array( $option_value ) ) { |
|
| 464 | - selected( in_array( $key, $option_value ), true ); |
|
| 463 | + if (is_array($option_value)) { |
|
| 464 | + selected(in_array($key, $option_value), true); |
|
| 465 | 465 | } else { |
| 466 | - selected( $option_value, $key ); |
|
| 466 | + selected($option_value, $key); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | ?>><?php echo $val ?></option> |
@@ -479,28 +479,28 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | // Radio inputs. |
| 481 | 481 | case 'radio_inline' : |
| 482 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
| 482 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
| 483 | 483 | case 'radio' : |
| 484 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 484 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 485 | 485 | ?> |
| 486 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 486 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 487 | 487 | <th scope="row" class="titledesc"> |
| 488 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 488 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 489 | 489 | </th> |
| 490 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 490 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 491 | 491 | <fieldset> |
| 492 | 492 | <ul> |
| 493 | 493 | <?php |
| 494 | - foreach ( $value['options'] as $key => $val ) { |
|
| 494 | + foreach ($value['options'] as $key => $val) { |
|
| 495 | 495 | ?> |
| 496 | 496 | <li> |
| 497 | 497 | <label><input |
| 498 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 498 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 499 | 499 | value="<?php echo $key; ?>" |
| 500 | 500 | type="radio" |
| 501 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 502 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 503 | - <?php checked( $key, $option_value ); ?> |
|
| 501 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 502 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 503 | + <?php checked($key, $option_value); ?> |
|
| 504 | 504 | /> <?php echo $val ?></label> |
| 505 | 505 | </li> |
| 506 | 506 | <?php |
@@ -514,21 +514,21 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | // Checkbox input. |
| 516 | 516 | case 'checkbox' : |
| 517 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 517 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 518 | 518 | ?> |
| 519 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 519 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 520 | 520 | <th scope="row" class="titledesc"> |
| 521 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 521 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 522 | 522 | </th> |
| 523 | 523 | <td class="give-forminp"> |
| 524 | 524 | <input |
| 525 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 526 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 525 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 526 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 527 | 527 | type="checkbox" |
| 528 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
| 528 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
| 529 | 529 | value="1" |
| 530 | - <?php checked( $option_value, 'on' ); ?> |
|
| 531 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 530 | + <?php checked($option_value, 'on'); ?> |
|
| 531 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 532 | 532 | /> |
| 533 | 533 | <?php echo $description; ?> |
| 534 | 534 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | // Multi Checkbox input. |
| 540 | 540 | case 'multicheck' : |
| 541 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 542 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
| 541 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 542 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
| 543 | 543 | ?> |
| 544 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 544 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 545 | 545 | <th scope="row" class="titledesc"> |
| 546 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 546 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 547 | 547 | </th> |
| 548 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 548 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 549 | 549 | <fieldset> |
| 550 | 550 | <ul> |
| 551 | 551 | <?php |
| 552 | - foreach ( $value['options'] as $key => $val ) { |
|
| 552 | + foreach ($value['options'] as $key => $val) { |
|
| 553 | 553 | ?> |
| 554 | 554 | <li> |
| 555 | 555 | <label> |
| 556 | 556 | <input |
| 557 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
| 557 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
| 558 | 558 | value="<?php echo $key; ?>" |
| 559 | 559 | type="checkbox" |
| 560 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 561 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 562 | - <?php if ( in_array( $key, $option_value ) ) { |
|
| 560 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 561 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 562 | + <?php if (in_array($key, $option_value)) { |
|
| 563 | 563 | echo 'checked="checked"'; |
| 564 | 564 | } ?> |
| 565 | 565 | /> <?php echo $val ?> |
@@ -578,35 +578,35 @@ discard block |
||
| 578 | 578 | // File input field. |
| 579 | 579 | case 'file' : |
| 580 | 580 | case 'media' : |
| 581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 582 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
| 583 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
| 584 | - |
|
| 585 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
| 586 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#'; |
|
| 587 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
| 588 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
| 581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 582 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $value['type'] ? 'File' : 'Image')), 'give'); |
|
| 583 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
| 584 | + |
|
| 585 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
| 586 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '#'; |
|
| 587 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
| 588 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
| 589 | 589 | ?> |
| 590 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 590 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 591 | 591 | <th scope="row" class="titledesc"> |
| 592 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 592 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 593 | 593 | </th> |
| 594 | 594 | <td class="give-forminp"> |
| 595 | 595 | <div class="give-field-wrap"> |
| 596 | 596 | <label for="<?php echo $value['id'] ?>"> |
| 597 | 597 | <input |
| 598 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 599 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 598 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 599 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 600 | 600 | type="text" |
| 601 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
| 601 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
| 602 | 602 | value="<?php echo $option_value; ?>" |
| 603 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 604 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 603 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 604 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 605 | 605 | /> <input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>"> |
| 606 | 606 | <?php echo $description ?> |
| 607 | 607 | <div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
| 608 | 608 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
| 609 | - <img src="<?php echo $preview_image_src ; ?>" alt=""> |
|
| 609 | + <img src="<?php echo $preview_image_src; ?>" alt=""> |
|
| 610 | 610 | </div> |
| 611 | 611 | </label> |
| 612 | 612 | </div> |
@@ -618,17 +618,17 @@ discard block |
||
| 618 | 618 | // WordPress Editor. |
| 619 | 619 | case 'wysiwyg' : |
| 620 | 620 | // Get option value. |
| 621 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 621 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 622 | 622 | |
| 623 | 623 | // Get editor settings. |
| 624 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
| 624 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
| 625 | 625 | ?> |
| 626 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 626 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 627 | 627 | <th scope="row" class="titledesc"> |
| 628 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 628 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 629 | 629 | </th> |
| 630 | 630 | <td class="give-forminp"> |
| 631 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
| 631 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
| 632 | 632 | <?php echo $description; ?> |
| 633 | 633 | </td> |
| 634 | 634 | </tr><?php |
@@ -637,9 +637,9 @@ discard block |
||
| 637 | 637 | // Custom: System setting field. |
| 638 | 638 | case 'system_info' : |
| 639 | 639 | ?> |
| 640 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 640 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 641 | 641 | <th scope="row" class="titledesc"> |
| 642 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 642 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 643 | 643 | </th> |
| 644 | 644 | <td class="give-forminp"> |
| 645 | 645 | <?php give_system_info_callback(); ?> |
@@ -650,14 +650,14 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | // Custom: Default gateways setting field. |
| 652 | 652 | case 'default_gateway' : |
| 653 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 653 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 654 | 654 | ?> |
| 655 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 655 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 656 | 656 | <th scope="row" class="titledesc"> |
| 657 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 657 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 658 | 658 | </th> |
| 659 | 659 | <td class="give-forminp"> |
| 660 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
| 660 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
| 661 | 661 | <?php echo $description; ?> |
| 662 | 662 | </td> |
| 663 | 663 | </tr><?php |
@@ -665,14 +665,14 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | // Custom: Enable gateways setting field. |
| 667 | 667 | case 'enabled_gateways' : |
| 668 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 668 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 669 | 669 | ?> |
| 670 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 670 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 671 | 671 | <th scope="row" class="titledesc"> |
| 672 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 672 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 673 | 673 | </th> |
| 674 | 674 | <td class="give-forminp"> |
| 675 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
| 675 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
| 676 | 676 | <?php echo $description; ?> |
| 677 | 677 | </td> |
| 678 | 678 | </tr><?php |
@@ -681,9 +681,9 @@ discard block |
||
| 681 | 681 | // Custom: Email preview buttons field. |
| 682 | 682 | case 'email_preview_buttons' : |
| 683 | 683 | ?> |
| 684 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 684 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 685 | 685 | <th scope="row" class="titledesc"> |
| 686 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 686 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 687 | 687 | </th> |
| 688 | 688 | <td class="give-forminp"> |
| 689 | 689 | <?php give_email_preview_buttons_callback(); ?> |
@@ -700,22 +700,22 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | // Custom: Gateway API key. |
| 702 | 702 | case 'api_key' : |
| 703 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 704 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
| 703 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 704 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
| 705 | 705 | ?> |
| 706 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 706 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 707 | 707 | <th scope="row" class="titledesc"> |
| 708 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 708 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 709 | 709 | </th> |
| 710 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 710 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 711 | 711 | <input |
| 712 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 713 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 714 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 715 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 716 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
| 717 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 718 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 712 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 713 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 714 | + type="<?php echo esc_attr($type); ?>" |
|
| 715 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 716 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
| 717 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 718 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 719 | 719 | /> <?php echo $description; ?> |
| 720 | 720 | </td> |
| 721 | 721 | </tr><?php |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | * |
| 733 | 733 | * @since 1.0 |
| 734 | 734 | */ |
| 735 | - do_action( "give_logs_view_{$current_section}" ); |
|
| 735 | + do_action("give_logs_view_{$current_section}"); |
|
| 736 | 736 | |
| 737 | 737 | echo $description; |
| 738 | 738 | break; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | // Custom: Data field. |
| 741 | 741 | case 'data' : |
| 742 | 742 | |
| 743 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
| 743 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
| 744 | 744 | |
| 745 | 745 | echo $description; |
| 746 | 746 | break; |
@@ -748,12 +748,12 @@ discard block |
||
| 748 | 748 | // Custom: Give Docs Link field type. |
| 749 | 749 | case 'give_docs_link' : |
| 750 | 750 | ?> |
| 751 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 751 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 752 | 752 | <td class="give-docs-link" colspan="2"> |
| 753 | 753 | <?php |
| 754 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
| 754 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
| 755 | 755 | . '" target="_blank">' |
| 756 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 756 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
| 757 | 757 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 758 | 758 | ?> |
| 759 | 759 | </td> |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | // You can add or handle your custom field action. |
| 765 | 765 | default: |
| 766 | 766 | // Get option value. |
| 767 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 768 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
| 767 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 768 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
| 769 | 769 | break; |
| 770 | 770 | } |
| 771 | 771 | } |
@@ -781,15 +781,15 @@ discard block |
||
| 781 | 781 | * |
| 782 | 782 | * @return string The HTML description of the field. |
| 783 | 783 | */ |
| 784 | - public static function get_field_description( $value ) { |
|
| 784 | + public static function get_field_description($value) { |
|
| 785 | 785 | $description = ''; |
| 786 | 786 | |
| 787 | 787 | // Support for both 'description' and 'desc' args. |
| 788 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
| 789 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
| 788 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
| 789 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
| 790 | 790 | |
| 791 | - if ( ! empty( $value ) ) { |
|
| 792 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
| 791 | + if ( ! empty($value)) { |
|
| 792 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | return $description; |
@@ -806,11 +806,11 @@ discard block |
||
| 806 | 806 | * |
| 807 | 807 | * @return array The description and tip as a 2 element array |
| 808 | 808 | */ |
| 809 | - public static function get_field_title( $value ) { |
|
| 810 | - $title = esc_html( $value['title'] ); |
|
| 809 | + public static function get_field_title($value) { |
|
| 810 | + $title = esc_html($value['title']); |
|
| 811 | 811 | |
| 812 | 812 | // If html tag detected then allow them to print. |
| 813 | - if ( strip_tags( $title ) ) { |
|
| 813 | + if (strip_tags($title)) { |
|
| 814 | 814 | $title = $value['title']; |
| 815 | 815 | } |
| 816 | 816 | |
@@ -829,8 +829,8 @@ discard block |
||
| 829 | 829 | * |
| 830 | 830 | * @return bool |
| 831 | 831 | */ |
| 832 | - public static function save_fields( $options, $option_name = '' ) { |
|
| 833 | - if ( empty( $_POST ) ) { |
|
| 832 | + public static function save_fields($options, $option_name = '') { |
|
| 833 | + if (empty($_POST)) { |
|
| 834 | 834 | return false; |
| 835 | 835 | } |
| 836 | 836 | |
@@ -838,37 +838,37 @@ discard block |
||
| 838 | 838 | $update_options = array(); |
| 839 | 839 | |
| 840 | 840 | // Loop options and get values to save. |
| 841 | - foreach ( $options as $option ) { |
|
| 842 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
| 841 | + foreach ($options as $option) { |
|
| 842 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
| 843 | 843 | continue; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | // Get posted value. |
| 847 | - if ( strstr( $option['id'], '[' ) ) { |
|
| 848 | - parse_str( $option['id'], $option_name_array ); |
|
| 849 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
| 850 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
| 851 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
| 847 | + if (strstr($option['id'], '[')) { |
|
| 848 | + parse_str($option['id'], $option_name_array); |
|
| 849 | + $field_option_name = current(array_keys($option_name_array)); |
|
| 850 | + $setting_name = key($option_name_array[$field_option_name]); |
|
| 851 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
| 852 | 852 | } else { |
| 853 | 853 | $field_option_name = $option['id']; |
| 854 | 854 | $setting_name = ''; |
| 855 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
| 855 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | // Format the value based on option type. |
| 859 | - switch ( $option['type'] ) { |
|
| 859 | + switch ($option['type']) { |
|
| 860 | 860 | case 'checkbox' : |
| 861 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
| 861 | + $value = is_null($raw_value) ? '' : 'on'; |
|
| 862 | 862 | break; |
| 863 | 863 | case 'wysiwyg' : |
| 864 | 864 | case 'textarea' : |
| 865 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
| 865 | + $value = wp_kses_post(trim($raw_value)); |
|
| 866 | 866 | break; |
| 867 | 867 | case 'multiselect' : |
| 868 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
| 868 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
| 869 | 869 | break; |
| 870 | 870 | default : |
| 871 | - $value = give_clean( $raw_value ); |
|
| 871 | + $value = give_clean($raw_value); |
|
| 872 | 872 | break; |
| 873 | 873 | } |
| 874 | 874 | |
@@ -877,37 +877,37 @@ discard block |
||
| 877 | 877 | * |
| 878 | 878 | * @since 1.8 |
| 879 | 879 | */ |
| 880 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
| 880 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | 883 | * Sanitize the value of an option by option name. |
| 884 | 884 | * |
| 885 | 885 | * @since 1.8 |
| 886 | 886 | */ |
| 887 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
| 887 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
| 888 | 888 | |
| 889 | - if ( is_null( $value ) ) { |
|
| 889 | + if (is_null($value)) { |
|
| 890 | 890 | continue; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | // Check if option is an array and handle that differently to single values. |
| 894 | - if ( $field_option_name && $setting_name ) { |
|
| 895 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
| 896 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
| 894 | + if ($field_option_name && $setting_name) { |
|
| 895 | + if ( ! isset($update_options[$field_option_name])) { |
|
| 896 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
| 897 | 897 | } |
| 898 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
| 899 | - $update_options[ $field_option_name ] = array(); |
|
| 898 | + if ( ! is_array($update_options[$field_option_name])) { |
|
| 899 | + $update_options[$field_option_name] = array(); |
|
| 900 | 900 | } |
| 901 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
| 901 | + $update_options[$field_option_name][$setting_name] = $value; |
|
| 902 | 902 | } else { |
| 903 | - $update_options[ $field_option_name ] = $value; |
|
| 903 | + $update_options[$field_option_name] = $value; |
|
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | // Save all options in our array or there own option name i.e. option id. |
| 908 | - if ( empty( $option_name ) ) { |
|
| 909 | - foreach ( $update_options as $name => $value ) { |
|
| 910 | - update_option( $name, $value ); |
|
| 908 | + if (empty($option_name)) { |
|
| 909 | + foreach ($update_options as $name => $value) { |
|
| 910 | + update_option($name, $value); |
|
| 911 | 911 | |
| 912 | 912 | /** |
| 913 | 913 | * Trigger action. |
@@ -916,13 +916,13 @@ discard block |
||
| 916 | 916 | * |
| 917 | 917 | * @since 1.8 |
| 918 | 918 | */ |
| 919 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
| 919 | + do_action("give_save_option_{$name}", $value, $name); |
|
| 920 | 920 | } |
| 921 | 921 | } else { |
| 922 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
| 923 | - $update_options = array_merge( $old_options, $update_options ); |
|
| 922 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
| 923 | + $update_options = array_merge($old_options, $update_options); |
|
| 924 | 924 | |
| 925 | - update_option( $option_name, $update_options ); |
|
| 925 | + update_option($option_name, $update_options); |
|
| 926 | 926 | |
| 927 | 927 | /** |
| 928 | 928 | * Trigger action. |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * |
| 932 | 932 | * @since 1.8 |
| 933 | 933 | */ |
| 934 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
| 934 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | return true; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,36 +23,36 @@ discard block |
||
| 23 | 23 | function give_setup_post_types() { |
| 24 | 24 | |
| 25 | 25 | // Give Forms single post and archive options. |
| 26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
| 27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
| 26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
| 27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
| 28 | 28 | |
| 29 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
| 29 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
| 30 | 30 | // Support for old 'GIVE_FORMS_SLUG' constant |
| 31 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
| 31 | + if (defined('GIVE_FORMS_SLUG')) { |
|
| 32 | 32 | $give_forms_slug = GIVE_FORMS_SLUG; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 35 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 36 | 36 | 'slug' => $give_forms_slug, |
| 37 | 37 | 'with_front' => false, |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
| 41 | - 'name' => __( 'Donation Forms', 'give' ), |
|
| 42 | - 'singular_name' => __( 'Form', 'give' ), |
|
| 43 | - 'add_new' => __( 'Add Form', 'give' ), |
|
| 44 | - 'add_new_item' => __( 'Add New Donation Form', 'give' ), |
|
| 45 | - 'edit_item' => __( 'Edit Donation Form', 'give' ), |
|
| 46 | - 'new_item' => __( 'New Form', 'give' ), |
|
| 47 | - 'all_items' => __( 'All Forms', 'give' ), |
|
| 48 | - 'view_item' => __( 'View Form', 'give' ), |
|
| 49 | - 'search_items' => __( 'Search Forms', 'give' ), |
|
| 50 | - 'not_found' => __( 'No forms found.', 'give' ), |
|
| 51 | - 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ), |
|
| 40 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
| 41 | + 'name' => __('Donation Forms', 'give'), |
|
| 42 | + 'singular_name' => __('Form', 'give'), |
|
| 43 | + 'add_new' => __('Add Form', 'give'), |
|
| 44 | + 'add_new_item' => __('Add New Donation Form', 'give'), |
|
| 45 | + 'edit_item' => __('Edit Donation Form', 'give'), |
|
| 46 | + 'new_item' => __('New Form', 'give'), |
|
| 47 | + 'all_items' => __('All Forms', 'give'), |
|
| 48 | + 'view_item' => __('View Form', 'give'), |
|
| 49 | + 'search_items' => __('Search Forms', 'give'), |
|
| 50 | + 'not_found' => __('No forms found.', 'give'), |
|
| 51 | + 'not_found_in_trash' => __('No forms found in Trash.', 'give'), |
|
| 52 | 52 | 'parent_item_colon' => '', |
| 53 | - 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ), |
|
| 54 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ), |
|
| 55 | - ) ); |
|
| 53 | + 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), |
|
| 54 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')), |
|
| 55 | + )); |
|
| 56 | 56 | |
| 57 | 57 | // Default give_forms supports. |
| 58 | 58 | $give_form_supports = array( |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | // Has the user disabled the excerpt? |
| 67 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
| 68 | - unset( $give_form_supports[2] ); |
|
| 67 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
| 68 | + unset($give_form_supports[2]); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Has user disabled the featured image? |
| 72 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 73 | - unset( $give_form_supports[1] ); |
|
| 74 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
| 72 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 73 | + unset($give_form_supports[1]); |
|
| 74 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $give_forms_args = array( |
@@ -87,42 +87,42 @@ discard block |
||
| 87 | 87 | 'has_archive' => $give_forms_archives, |
| 88 | 88 | 'menu_icon' => 'dashicons-give', |
| 89 | 89 | 'hierarchical' => false, |
| 90 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
| 90 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
| 91 | 91 | ); |
| 92 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
| 92 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
| 93 | 93 | |
| 94 | 94 | /** Donation Post Type */ |
| 95 | 95 | $payment_labels = array( |
| 96 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
| 97 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
| 98 | - 'add_new' => __( 'Add New', 'give' ), |
|
| 99 | - 'add_new_item' => __( 'Add New Donation', 'give' ), |
|
| 100 | - 'edit_item' => __( 'Edit Donation', 'give' ), |
|
| 101 | - 'new_item' => __( 'New Donation', 'give' ), |
|
| 102 | - 'all_items' => __( 'All Donations', 'give' ), |
|
| 103 | - 'view_item' => __( 'View Donation', 'give' ), |
|
| 104 | - 'search_items' => __( 'Search Donations', 'give' ), |
|
| 105 | - 'not_found' => __( 'No donations found.', 'give' ), |
|
| 106 | - 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ), |
|
| 96 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
| 97 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
| 98 | + 'add_new' => __('Add New', 'give'), |
|
| 99 | + 'add_new_item' => __('Add New Donation', 'give'), |
|
| 100 | + 'edit_item' => __('Edit Donation', 'give'), |
|
| 101 | + 'new_item' => __('New Donation', 'give'), |
|
| 102 | + 'all_items' => __('All Donations', 'give'), |
|
| 103 | + 'view_item' => __('View Donation', 'give'), |
|
| 104 | + 'search_items' => __('Search Donations', 'give'), |
|
| 105 | + 'not_found' => __('No donations found.', 'give'), |
|
| 106 | + 'not_found_in_trash' => __('No donations found in Trash.', 'give'), |
|
| 107 | 107 | 'parent_item_colon' => '', |
| 108 | - 'menu_name' => __( 'Donations', 'give' ), |
|
| 108 | + 'menu_name' => __('Donations', 'give'), |
|
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | 111 | $payment_args = array( |
| 112 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
| 112 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
| 113 | 113 | 'public' => false, |
| 114 | 114 | 'query_var' => false, |
| 115 | 115 | 'rewrite' => false, |
| 116 | 116 | 'map_meta_cap' => true, |
| 117 | 117 | 'capability_type' => 'give_payment', |
| 118 | - 'supports' => array( 'title' ), |
|
| 118 | + 'supports' => array('title'), |
|
| 119 | 119 | 'can_export' => true, |
| 120 | 120 | ); |
| 121 | - register_post_type( 'give_payment', $payment_args ); |
|
| 121 | + register_post_type('give_payment', $payment_args); |
|
| 122 | 122 | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
| 125 | +add_action('init', 'give_setup_post_types', 1); |
|
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,30 +135,30 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | function give_setup_taxonomies() { |
| 137 | 137 | |
| 138 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
| 138 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
| 139 | 139 | |
| 140 | 140 | /** Categories */ |
| 141 | 141 | $category_labels = array( |
| 142 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
| 143 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
| 144 | - 'search_items' => __( 'Search Categories', 'give' ), |
|
| 145 | - 'all_items' => __( 'All Categories', 'give' ), |
|
| 146 | - 'parent_item' => __( 'Parent Category', 'give' ), |
|
| 147 | - 'parent_item_colon' => __( 'Parent Category:', 'give' ), |
|
| 148 | - 'edit_item' => __( 'Edit Category', 'give' ), |
|
| 149 | - 'update_item' => __( 'Update Category', 'give' ), |
|
| 150 | - 'add_new_item' => __( 'Add New Category', 'give' ), |
|
| 151 | - 'new_item_name' => __( 'New Category Name', 'give' ), |
|
| 152 | - 'menu_name' => __( 'Categories', 'give' ), |
|
| 142 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
| 143 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
| 144 | + 'search_items' => __('Search Categories', 'give'), |
|
| 145 | + 'all_items' => __('All Categories', 'give'), |
|
| 146 | + 'parent_item' => __('Parent Category', 'give'), |
|
| 147 | + 'parent_item_colon' => __('Parent Category:', 'give'), |
|
| 148 | + 'edit_item' => __('Edit Category', 'give'), |
|
| 149 | + 'update_item' => __('Update Category', 'give'), |
|
| 150 | + 'add_new_item' => __('Add New Category', 'give'), |
|
| 151 | + 'new_item_name' => __('New Category Name', 'give'), |
|
| 152 | + 'menu_name' => __('Categories', 'give'), |
|
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
| 155 | + $category_args = apply_filters('give_forms_category_args', array( |
|
| 156 | 156 | 'hierarchical' => true, |
| 157 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
| 157 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
| 158 | 158 | 'show_ui' => true, |
| 159 | 159 | 'query_var' => 'give_forms_category', |
| 160 | 160 | 'rewrite' => array( |
| 161 | - 'slug' => $slug . '/category', |
|
| 161 | + 'slug' => $slug.'/category', |
|
| 162 | 162 | 'with_front' => false, |
| 163 | 163 | 'hierarchical' => true, |
| 164 | 164 | ), |
@@ -172,33 +172,33 @@ discard block |
||
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | 174 | // Does the user want categories? |
| 175 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
| 176 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
| 177 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
| 175 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
| 176 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
| 177 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** Tags */ |
| 181 | 181 | $tag_labels = array( |
| 182 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
| 183 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
| 184 | - 'search_items' => __( 'Search Tags', 'give' ), |
|
| 185 | - 'all_items' => __( 'All Tags', 'give' ), |
|
| 186 | - 'parent_item' => __( 'Parent Tag', 'give' ), |
|
| 187 | - 'parent_item_colon' => __( 'Parent Tag:', 'give' ), |
|
| 188 | - 'edit_item' => __( 'Edit Tag', 'give' ), |
|
| 189 | - 'update_item' => __( 'Update Tag', 'give' ), |
|
| 190 | - 'add_new_item' => __( 'Add New Tag', 'give' ), |
|
| 191 | - 'new_item_name' => __( 'New Tag Name', 'give' ), |
|
| 192 | - 'menu_name' => __( 'Tags', 'give' ), |
|
| 193 | - 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ), |
|
| 182 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
| 183 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
| 184 | + 'search_items' => __('Search Tags', 'give'), |
|
| 185 | + 'all_items' => __('All Tags', 'give'), |
|
| 186 | + 'parent_item' => __('Parent Tag', 'give'), |
|
| 187 | + 'parent_item_colon' => __('Parent Tag:', 'give'), |
|
| 188 | + 'edit_item' => __('Edit Tag', 'give'), |
|
| 189 | + 'update_item' => __('Update Tag', 'give'), |
|
| 190 | + 'add_new_item' => __('Add New Tag', 'give'), |
|
| 191 | + 'new_item_name' => __('New Tag Name', 'give'), |
|
| 192 | + 'menu_name' => __('Tags', 'give'), |
|
| 193 | + 'choose_from_most_used' => __('Choose from most used tags.', 'give'), |
|
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
| 196 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
| 197 | 197 | 'hierarchical' => false, |
| 198 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
| 198 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
| 199 | 199 | 'show_ui' => true, |
| 200 | 200 | 'query_var' => 'give_forms_tag', |
| 201 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
| 201 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
| 202 | 202 | 'capabilities' => array( |
| 203 | 203 | 'manage_terms' => 'manage_give_form_terms', |
| 204 | 204 | 'edit_terms' => 'edit_give_form_terms', |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | ) |
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
| 212 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
| 213 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
| 211 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
| 212 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
| 213 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
| 218 | +add_action('init', 'give_setup_taxonomies', 0); |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function give_get_default_form_labels() { |
| 228 | 228 | $defaults = array( |
| 229 | - 'singular' => __( 'Form', 'give' ), |
|
| 230 | - 'plural' => __( 'Forms', 'give' ), |
|
| 229 | + 'singular' => __('Form', 'give'), |
|
| 230 | + 'plural' => __('Forms', 'give'), |
|
| 231 | 231 | ); |
| 232 | 232 | |
| 233 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
| 233 | + return apply_filters('give_default_form_name', $defaults); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return string $defaults['singular'] Singular label |
| 244 | 244 | */ |
| 245 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
| 245 | +function give_get_forms_label_singular($lowercase = false) { |
|
| 246 | 246 | $defaults = give_get_default_form_labels(); |
| 247 | 247 | |
| 248 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 248 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | * @since 1.0 |
| 255 | 255 | * @return string $defaults['plural'] Plural label |
| 256 | 256 | */ |
| 257 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
| 257 | +function give_get_forms_label_plural($lowercase = false) { |
|
| 258 | 258 | $defaults = give_get_default_form_labels(); |
| 259 | 259 | |
| 260 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 260 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -269,24 +269,24 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string $title New placeholder text |
| 271 | 271 | */ |
| 272 | -function give_change_default_title( $title ) { |
|
| 272 | +function give_change_default_title($title) { |
|
| 273 | 273 | // If a frontend plugin uses this filter (check extensions before changing this function) |
| 274 | - if ( ! is_admin() ) { |
|
| 275 | - $title = __( 'Enter form title here', 'give' ); |
|
| 274 | + if ( ! is_admin()) { |
|
| 275 | + $title = __('Enter form title here', 'give'); |
|
| 276 | 276 | |
| 277 | 277 | return $title; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $screen = get_current_screen(); |
| 281 | 281 | |
| 282 | - if ( 'give_forms' == $screen->post_type ) { |
|
| 283 | - $title = __( 'Enter form title here', 'give' ); |
|
| 282 | + if ('give_forms' == $screen->post_type) { |
|
| 283 | + $title = __('Enter form title here', 'give'); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | return $title; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
| 289 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
| 290 | 290 | |
| 291 | 291 | /** |
| 292 | 292 | * Registers Custom Post Statuses which are used by the Payments |
@@ -296,58 +296,58 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | function give_register_post_type_statuses() { |
| 298 | 298 | // Payment Statuses |
| 299 | - register_post_status( 'refunded', array( |
|
| 300 | - 'label' => __( 'Refunded', 'give' ), |
|
| 299 | + register_post_status('refunded', array( |
|
| 300 | + 'label' => __('Refunded', 'give'), |
|
| 301 | 301 | 'public' => true, |
| 302 | 302 | 'exclude_from_search' => false, |
| 303 | 303 | 'show_in_admin_all_list' => true, |
| 304 | 304 | 'show_in_admin_status_list' => true, |
| 305 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
| 306 | - ) ); |
|
| 307 | - register_post_status( 'failed', array( |
|
| 308 | - 'label' => __( 'Failed', 'give' ), |
|
| 305 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
| 306 | + )); |
|
| 307 | + register_post_status('failed', array( |
|
| 308 | + 'label' => __('Failed', 'give'), |
|
| 309 | 309 | 'public' => true, |
| 310 | 310 | 'exclude_from_search' => false, |
| 311 | 311 | 'show_in_admin_all_list' => true, |
| 312 | 312 | 'show_in_admin_status_list' => true, |
| 313 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
| 314 | - ) ); |
|
| 315 | - register_post_status( 'revoked', array( |
|
| 316 | - 'label' => __( 'Revoked', 'give' ), |
|
| 313 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
| 314 | + )); |
|
| 315 | + register_post_status('revoked', array( |
|
| 316 | + 'label' => __('Revoked', 'give'), |
|
| 317 | 317 | 'public' => true, |
| 318 | 318 | 'exclude_from_search' => false, |
| 319 | 319 | 'show_in_admin_all_list' => true, |
| 320 | 320 | 'show_in_admin_status_list' => true, |
| 321 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
| 322 | - ) ); |
|
| 323 | - register_post_status( 'cancelled', array( |
|
| 324 | - 'label' => __( 'Cancelled', 'give' ), |
|
| 321 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
| 322 | + )); |
|
| 323 | + register_post_status('cancelled', array( |
|
| 324 | + 'label' => __('Cancelled', 'give'), |
|
| 325 | 325 | 'public' => true, |
| 326 | 326 | 'exclude_from_search' => false, |
| 327 | 327 | 'show_in_admin_all_list' => true, |
| 328 | 328 | 'show_in_admin_status_list' => true, |
| 329 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
| 330 | - ) ); |
|
| 331 | - register_post_status( 'abandoned', array( |
|
| 332 | - 'label' => __( 'Abandoned', 'give' ), |
|
| 329 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
| 330 | + )); |
|
| 331 | + register_post_status('abandoned', array( |
|
| 332 | + 'label' => __('Abandoned', 'give'), |
|
| 333 | 333 | 'public' => true, |
| 334 | 334 | 'exclude_from_search' => false, |
| 335 | 335 | 'show_in_admin_all_list' => true, |
| 336 | 336 | 'show_in_admin_status_list' => true, |
| 337 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
| 338 | - ) ); |
|
| 339 | - register_post_status( 'processing', array( |
|
| 340 | - 'label' => _x( 'Processing', 'Processing payment status', 'give' ), |
|
| 337 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
| 338 | + )); |
|
| 339 | + register_post_status('processing', array( |
|
| 340 | + 'label' => _x('Processing', 'Processing payment status', 'give'), |
|
| 341 | 341 | 'public' => true, |
| 342 | 342 | 'exclude_from_search' => false, |
| 343 | 343 | 'show_in_admin_all_list' => true, |
| 344 | 344 | 'show_in_admin_status_list' => true, |
| 345 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' ) |
|
| 346 | - ) ); |
|
| 345 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give') |
|
| 346 | + )); |
|
| 347 | 347 | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
| 350 | +add_action('init', 'give_register_post_type_statuses'); |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Updated Messages |
@@ -360,27 +360,27 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @return array $messages New post updated messages |
| 362 | 362 | */ |
| 363 | -function give_updated_messages( $messages ) { |
|
| 363 | +function give_updated_messages($messages) { |
|
| 364 | 364 | global $post, $post_ID; |
| 365 | 365 | |
| 366 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
|
| 366 | + if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) { |
|
| 367 | 367 | |
| 368 | 368 | $messages['give_forms'] = array( |
| 369 | - 1 => __( 'Form updated.', 'give' ), |
|
| 370 | - 4 => __( 'Form updated.', 'give' ), |
|
| 371 | - 6 => __( 'Form published.', 'give' ), |
|
| 372 | - 7 => __( 'Form saved.', 'give' ), |
|
| 373 | - 8 => __( 'Form submitted.', 'give' ), |
|
| 369 | + 1 => __('Form updated.', 'give'), |
|
| 370 | + 4 => __('Form updated.', 'give'), |
|
| 371 | + 6 => __('Form published.', 'give'), |
|
| 372 | + 7 => __('Form saved.', 'give'), |
|
| 373 | + 8 => __('Form submitted.', 'give'), |
|
| 374 | 374 | ); |
| 375 | 375 | |
| 376 | 376 | } else { |
| 377 | 377 | |
| 378 | 378 | $messages['give_forms'] = array( |
| 379 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 380 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 381 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 382 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 383 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 379 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 380 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 381 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 382 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 383 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 384 | 384 | ); |
| 385 | 385 | |
| 386 | 386 | } |
@@ -388,27 +388,27 @@ discard block |
||
| 388 | 388 | return $messages; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
| 391 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
| 392 | 392 | |
| 393 | 393 | |
| 394 | 394 | /** |
| 395 | 395 | * Setup Post Type Images |
| 396 | 396 | */ |
| 397 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
| 397 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | 400 | * Ensure post thumbnail support is turned on |
| 401 | 401 | */ |
| 402 | 402 | function give_add_thumbnail_support() { |
| 403 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 403 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
| 408 | - add_theme_support( 'post-thumbnails' ); |
|
| 407 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
| 408 | + add_theme_support('post-thumbnails'); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
| 411 | + add_post_type_support('give_forms', 'thumbnail'); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -420,21 +420,21 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // Single Give Forms (disabled if single turned off in settings) |
| 422 | 422 | if ( |
| 423 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
| 424 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
| 423 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
| 424 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
| 425 | 425 | ) { |
| 426 | 426 | |
| 427 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
| 428 | - 'name' => __( 'Give Single Form Sidebar', 'give' ), |
|
| 427 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
| 428 | + 'name' => __('Give Single Form Sidebar', 'give'), |
|
| 429 | 429 | 'id' => 'give-forms-sidebar', |
| 430 | - 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
| 430 | + 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
| 431 | 431 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
| 432 | 432 | 'after_widget' => '</div>', |
| 433 | 433 | 'before_title' => '<h3 class="widgettitle widget-title">', |
| 434 | 434 | 'after_title' => '</h3>', |
| 435 | - ) ) ); |
|
| 435 | + ))); |
|
| 436 | 436 | |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
| 440 | +add_action('widgets_init', 'give_widgets_init', 999); |
|