1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
<?php
if (!function_exists('asa2_option_is_short_url')) {
/**
* Shortcut to check if the option to use short URLs is enabled.
*
* Example:
* ```php
* if (asa2_option_is_short_url()) {
* // shorten URL here
* }
* ```
* @since 1.8.0
* @package OptionsShortcuts
* @return bool
*/
function asa2_option_is_short_url() {
return asa2_option_is('asa2_short_url');
}
}
if (!function_exists('asa2_option_short_url_format')) {
/**
* Shortcut to get the selected short URL format.
*
* Example:
* ```php
* $shortUrlFormat = asa2_option_short_url_format();
* ```
* @since 1.8.0
* @package OptionsShortcuts
* @return int|null
*/
function asa2_option_short_url_format() {
if (class_exists('Asa2_Service_Stores') && class_exists('Ifw_Wp_Plugin_Manager')) {
return Asa2_Service_Stores::sanitizeShortUrlFormat((int)Ifw_Wp_Plugin_Manager::getInstance('Asa2')->getOption('short_url_format'));
}
return null;
}
}
if (!function_exists('asa2_option_is_parse_comments')) {
/**
* Shortcut to check if URL Replacer option to parse comments texts is enabled.
*
* Example:
* ```php
* if (asa2_option_is_parse_comments()) {
* // parse comments texts
* }
* ```
* @since 1.8.0
* @package OptionsShortcuts
* @return bool
*/
function asa2_option_is_parse_comments() {
return asa2_option_is('parse_comments');
}
}
if (!function_exists('asa2_option_is_parse_posts')) {
/**
* Shortcut to check if URL Replacer option to parse posts texts is enabled.
*
* Example:
* ```php
* if (asa2_option_is_parse_posts()) {
* // parse posts texts
* }
* ```
* @since 1.8.0
* @package OptionsShortcuts
* @return bool
*/
function asa2_option_is_parse_posts() {
return asa2_option_is('parse_posts');
}
}
if (!function_exists('asa2_option_is_parse_widgets')) {
/**
* Shortcut to check if URL Replacer option to parse widget texts is enabled.
*
* Example:
* ```php
* if (asa2_option_is_parse_widgets()) {
* // parse widget texts
* }
* ```
* @since 1.8.0
* @package OptionsShortcuts
*
* @return bool
*/
function asa2_option_is_parse_widgets() {
return asa2_option_is('parse_widgets');
}
}
if (!function_exists('asa2_option_is_disable_asin_filter')) {
/**
* Shortcut to check if ASIN filter is disabled.
*
* Example:
* ```php
* if (asa2_option_is_disable_asin_filter()) {
* // do this if ASIN filter is disabled
* }
* ```
* @since 1.8.0
* @package OptionsShortcuts
* @return bool
*/
function asa2_option_is_disable_asin_filter() {
return asa2_option_is('disable_asin_filter');
}
}
if (!function_exists('asa2_option_is_i18n')) {
/**
* Shortcut to check if i18n option is activated.
*
* Example:
* ```php
* if (asa2_option_is_i18n()) {
* // do this if i18n is activated
* }
* ```
*
* @since 1.8.0
* @package OptionsShortcuts
*
* @return bool
*/
function asa2_option_is_i18n() {
return asa2_option_is('repo_i18n');
}
}
if (!function_exists('asa2_option_get')) {
/**
* Get the value of an ASA2 option.
*
* Example:
* ```php
* $asa2_widget_class = asa2_option_get('widget_collection_css_outer');
* // $asa2_widget_class contains the value of ASA2 option "Collection widget class"
* ```
*
* @since 1.8.0
* @package Options
*
* @param string $key The option key
* @param mixed $default Default value to return if option is empty. Default: null
* @return mixed
*/
function asa2_option_get($key, $default = null) {
if (class_exists('Ifw_Wp_Plugin_Manager') && Ifw_Wp_Plugin_Manager::getInstance('Asa2')->hasOption($key)) {
return Ifw_Wp_Plugin_Manager::getInstance('Asa2')->getOption($key, $default);
}
return $default;
}
}
if (!function_exists('asa2_option_is')) {
/**
* Checks if an option has a positive value, what means activated in case of a checkbox.
*
* Example:
* ```php
* if (asa2_option_is('disable_asin_filter')) {
* // option "Disable ASIN filter" is activated
* }
* ```
*
* @since 1.8.0
* @package Options
*
* @param string $key The option key
* @return bool
*/
function asa2_option_is($key) {
$result = asa2_option_get($key);
return !empty($result);
}
}
if (!function_exists('asa2_option_is_empty')) {
/**
* Checks whether an option has an empty value.
*
* Example:
* ```php
* if (asa2_option_is_empty('widget_collection_css_outer')) {
* // option "Collection widget class" is empty
* }
* ```
*
* @since 1.8.0
* @package Options
*
* @param string $key The option key
* @return bool
*/
function asa2_option_is_empty($key) {
$result = asa2_option_get($key);
return empty($result);
}
}
if (!function_exists('asa2_option_is_not_empty')) {
/**
* Checks whether an option has no empty value.
*
* Example:
* ```php
* if (asa2_option_is_not_empty('default_feed_category_name')) {
* // option "Default category name" for feeds has a value to work with
* }
* ```
*
* @since 1.8.0
* @package Options
*
* @param string $key The option key
* @return bool
*/
function asa2_option_is_not_empty($key) {
return !asa2_option_is_empty($key);
}
}