| 1 |
<?php |
| 2 |
namespace ULTP; |
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
class Option_Addons{ |
| 7 |
public function __construct() { |
| 8 |
$this->create_admin_page(); |
| 9 |
add_filter('ultp_settings', array($this, 'get_addon_settings'), 10, 1); |
| 10 |
} |
| 11 |
|
| 12 |
|
| 13 |
public static function get_addon_settings($config) { |
| 14 |
$arr = array( |
| 15 |
'addon' => array( |
| 16 |
'label' => __('Blocks', 'ultimate-post'), |
| 17 |
'attr' => array( |
| 18 |
'addon_enable' => array( |
| 19 |
'type' => 'heading', |
| 20 |
'label' => __('Enable/Disable Blocks', 'ultimate-post'), |
| 21 |
), |
| 22 |
'post_grid_1' => array( |
| 23 |
'type' => 'switch', |
| 24 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 25 |
'default' => true, |
| 26 |
'desc' => __('Post Grid #1 Block.', 'ultimate-post') |
| 27 |
), |
| 28 |
'post_grid_2' => array( |
| 29 |
'type' => 'switch', |
| 30 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 31 |
'default' => true, |
| 32 |
'desc' => __('Post Grid #2 Block.', 'ultimate-post') |
| 33 |
), |
| 34 |
'post_grid_3' => array( |
| 35 |
'type' => 'switch', |
| 36 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 37 |
'default' => true, |
| 38 |
'desc' => __('Post Grid #3 Block.', 'ultimate-post') |
| 39 |
), |
| 40 |
'post_grid_4' => array( |
| 41 |
'type' => 'switch', |
| 42 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 43 |
'default' => true, |
| 44 |
'desc' => __('Post Grid #4 Block.', 'ultimate-post') |
| 45 |
), |
| 46 |
'post_grid_5' => array( |
| 47 |
'type' => 'switch', |
| 48 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 49 |
'default' => true, |
| 50 |
'desc' => __('Post Grid #5 Block.', 'ultimate-post') |
| 51 |
), |
| 52 |
'post_grid_6' => array( |
| 53 |
'type' => 'switch', |
| 54 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 55 |
'default' => true, |
| 56 |
'desc' => __('Post Grid #6 Block.', 'ultimate-post') |
| 57 |
), |
| 58 |
'post_grid_7' => array( |
| 59 |
'type' => 'switch', |
| 60 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 61 |
'default' => true, |
| 62 |
'desc' => __('Post Grid #7 Block.', 'ultimate-post') |
| 63 |
), |
| 64 |
'post_list_1' => array( |
| 65 |
'type' => 'switch', |
| 66 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 67 |
'default' => true, |
| 68 |
'desc' => __('Post List #1 Block.', 'ultimate-post') |
| 69 |
), |
| 70 |
'post_list_2' => array( |
| 71 |
'type' => 'switch', |
| 72 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 73 |
'default' => true, |
| 74 |
'desc' => __('Post List #2 Block.', 'ultimate-post') |
| 75 |
), |
| 76 |
'post_list_3' => array( |
| 77 |
'type' => 'switch', |
| 78 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 79 |
'default' => true, |
| 80 |
'desc' => __('Post List #3 Block.', 'ultimate-post') |
| 81 |
), |
| 82 |
'post_list_4' => array( |
| 83 |
'type' => 'switch', |
| 84 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 85 |
'default' => true, |
| 86 |
'desc' => __('Post List #4 Block.', 'ultimate-post') |
| 87 |
), |
| 88 |
'post_module_1' => array( |
| 89 |
'type' => 'switch', |
| 90 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 91 |
'default' => true, |
| 92 |
'desc' => __('Post Module #1 Block.', 'ultimate-post') |
| 93 |
), |
| 94 |
'post_module_2' => array( |
| 95 |
'type' => 'switch', |
| 96 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 97 |
'default' => true, |
| 98 |
'desc' => __('Post Module #2 Block.', 'ultimate-post') |
| 99 |
), |
| 100 |
'post_slider_1' => array( |
| 101 |
'type' => 'switch', |
| 102 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 103 |
'default' => true, |
| 104 |
'desc' => __('Post Slider #1 Block.', 'ultimate-post') |
| 105 |
), |
| 106 |
'heading' => array( |
| 107 |
'type' => 'switch', |
| 108 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 109 |
'default' => true, |
| 110 |
'desc' => __('Heading Block.', 'ultimate-post') |
| 111 |
), |
| 112 |
'image' => array( |
| 113 |
'type' => 'switch', |
| 114 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 115 |
'default' => true, |
| 116 |
'desc' => __('Image Block.', 'ultimate-post') |
| 117 |
), |
| 118 |
'taxonomy' => array( |
| 119 |
'type' => 'switch', |
| 120 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 121 |
'default' => true, |
| 122 |
'desc' => __('Taxonomy Block.', 'ultimate-post') |
| 123 |
), |
| 124 |
'wrapper' => array( |
| 125 |
'type' => 'switch', |
| 126 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 127 |
'default' => true, |
| 128 |
'desc' => __('Wrapper Block.', 'ultimate-post') |
| 129 |
) |
| 130 |
) |
| 131 |
) |
| 132 |
); |
| 133 |
return array_merge($config, $arr); |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
public static function all_addons(){ |
| 138 |
$all_addons = array( |
| 139 |
'ultp_category' => array( |
| 140 |
'name' => __( 'Category', 'ultimate-post' ), |
| 141 |
'desc' => __( 'Choose your desired color and Image for categories or any taxonomy.', 'ultimate-post' ), |
| 142 |
'img' => ULTP_URL.'/assets/img/addons/category-style.svg', |
| 143 |
'is_pro' => true, |
| 144 |
'docs' => 'https://docs.wpxpo.com/docs/postx/', |
| 145 |
'live' => 'https://www.wpxpo.com/postx/addons/category/' |
| 146 |
), |
| 147 |
'ultp_builder' => array( |
| 148 |
'name' => __( 'Builder', 'ultimate-post' ), |
| 149 |
'desc' => __( 'Design template for Archive, Category, Custom Taxonomy, Date, and Search Page.', 'ultimate-post' ), |
| 150 |
'img' => ULTP_URL.'/assets/img/addons/builder-icon.svg', |
| 151 |
'is_pro' => true, |
| 152 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/archive-builder/', |
| 153 |
'live' => 'https://www.wpxpo.com/postx/addons/builder/' |
| 154 |
), |
| 155 |
'ultp_progressbar' => array( |
| 156 |
'name' => __( 'Progressbar', 'ultimate-post' ), |
| 157 |
'desc' => __( 'Let the users see a graphical indicator to know the reading progress of a blog post.', 'ultimate-post' ), |
| 158 |
'img' => ULTP_URL.'/assets/img/addons/progressbar.svg', |
| 159 |
'is_pro' => true, |
| 160 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/progress-bar/', |
| 161 |
'live' => 'https://www.wpxpo.com/postx/progress-bar/' |
| 162 |
), |
| 163 |
'ultp_yoast' => array( |
| 164 |
'name' => __( 'Yoast Meta', 'ultimate-post' ), |
| 165 |
'desc' => __( 'Show Yoast meta description in the excerpt.', 'ultimate-post' ), |
| 166 |
'img' => ULTP_URL.'/assets/img/addons/yoast.svg', |
| 167 |
'is_pro' => true, |
| 168 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 169 |
'live' => 'https://www.wpxpo.com/postx/addons/yoast/', |
| 170 |
'required' => array( |
| 171 |
'name' => 'Yoast', |
| 172 |
'slug' => 'wordpress-seo/wp-seo.php' |
| 173 |
) |
| 174 |
), |
| 175 |
'ultp_aioseo' => array( |
| 176 |
'name' => __( 'All in One SEO Meta', 'ultimate-post' ), |
| 177 |
'desc' => __( 'Show All in One SEO meta description in the excerpt.', 'ultimate-post' ), |
| 178 |
'img' => ULTP_URL.'/assets/img/addons/aioseo.svg', |
| 179 |
'is_pro' => true, |
| 180 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 181 |
'live' => 'https://www.wpxpo.com/postx/addons/all-in-one-seo-meta/', |
| 182 |
'required' => array( |
| 183 |
'name' => 'All in One SEO', |
| 184 |
'slug' => 'all-in-one-seo-pack/all_in_one_seo_pack.php' |
| 185 |
) |
| 186 |
), |
| 187 |
'ultp_rankmath' => array( |
| 188 |
'name' => __( 'RankMath Meta', 'ultimate-post' ), |
| 189 |
'desc' => __( 'Show RankMath meta description in the excerpt.', 'ultimate-post' ), |
| 190 |
'img' => ULTP_URL.'/assets/img/addons/rankmath.svg', |
| 191 |
'is_pro' => true, |
| 192 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 193 |
'live' => 'https://www.wpxpo.com/postx/addons/rankmath/', |
| 194 |
'required' => array( |
| 195 |
'name' => 'RankMath', |
| 196 |
'slug' => 'seo-by-rank-math/rank-math.php' |
| 197 |
) |
| 198 |
), |
| 199 |
'ultp_seopress' => array( |
| 200 |
'name' => __( 'SEOPress Meta', 'ultimate-post' ), |
| 201 |
'desc' => __( 'Show SEOPress meta description in the excerpt.', 'ultimate-post' ), |
| 202 |
'img' => ULTP_URL.'/assets/img/addons/seopress.svg', |
| 203 |
'is_pro' => true, |
| 204 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 205 |
'live' => 'https://www.wpxpo.com/postx/addons/seopress/', |
| 206 |
'required' => array( |
| 207 |
'name' => 'SEOPress', |
| 208 |
'slug' => 'wp-seopress/seopress.php' |
| 209 |
) |
| 210 |
), |
| 211 |
'ultp_squirrly' => array( |
| 212 |
'name' => __( 'Squirrly Meta', 'ultimate-post' ), |
| 213 |
'desc' => __( 'Show Squirrly meta description in the excerpt.', 'ultimate-post' ), |
| 214 |
'img' => ULTP_URL.'/assets/img/addons/squirrly.svg', |
| 215 |
'is_pro' => true, |
| 216 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 217 |
'live' => 'https://www.wpxpo.com/postx/addons/squirrly/', |
| 218 |
'required' => array( |
| 219 |
'name' => 'Squirrly', |
| 220 |
'slug' => 'squirrly-seo/squirrly.php' |
| 221 |
), |
| 222 |
), |
| 223 |
); |
| 224 |
return apply_filters('ultp_addons_config', $all_addons); |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
/** |
| 229 |
* Settings page output |
| 230 |
*/ |
| 231 |
public function create_admin_page() { ?> |
| 232 |
|
| 233 |
<div class="ultp-dashboard-container"> |
| 234 |
|
| 235 |
<!-- addons content --> |
| 236 |
<div class="ultp-dashboard-body ultp-addons-content is-blank"> |
| 237 |
|
| 238 |
<!-- Pro Popup Container --> |
| 239 |
<div class="ultp-popup-container popup-center"> |
| 240 |
<div class="ultp-unlock-popup ultp-unlock-modal"> |
| 241 |
<img src="<?php echo esc_url(ULTP_URL . '/assets/img/admin/dashboard/unlock-super-icon.svg'); ?>" alt="lock icon"> |
| 242 |
<div class="ultp-popup-heading"><?php esc_html_e('Unlock 11+ Addons', 'ultimate-post'); ?></div> |
| 243 |
<div class="ultp-popup-desc"> |
| 244 |
<?php esc_html_e('We’re sorry, PostX Addons are not available on PostX free. Please upgrade to a PRO plan to unlock the add ons of your choice.', 'ultimate-post'); ?> |
| 245 |
</div> |
| 246 |
<a href="<?php echo esc_url(ultimate_post()->get_premium_link('', 'postx_dashboard_addons_popup')); ?>" class="ultp-popup-planbtn"><?php esc_html_e('Upgrade Plan', 'ultimate-post'); ?></a> |
| 247 |
<button class="ultp-popup-close"></button> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
|
| 251 |
<div class="ultp-addon-heading"> |
| 252 |
<?php _e('All Addons', 'ultimate-post'); ?> |
| 253 |
</div> |
| 254 |
|
| 255 |
<div class="ultp-addons-grid"> |
| 256 |
<?php |
| 257 |
$settings = apply_filters('ultp_settings', []); |
| 258 |
$option_value = ultimate_post()->get_setting(); |
| 259 |
$addons_data = self::all_addons(); |
| 260 |
foreach ($addons_data as $key => $val) { |
| 261 |
$require_plugin = ''; |
| 262 |
if (isset($val['required'])) { |
| 263 |
$active_plugins = get_option( 'active_plugins', array() ); |
| 264 |
if (is_multisite()) { |
| 265 |
$active_plugins = array_merge($active_plugins, array_keys(get_site_option( 'active_sitewide_plugins', array() ))); |
| 266 |
} |
| 267 |
if ( !in_array($val['required']['slug'], apply_filters('active_plugins', $active_plugins)) ) { |
| 268 |
$require_plugin = $val['required']['name']; |
| 269 |
} |
| 270 |
} |
| 271 |
?> |
| 272 |
<div class="ultp-content-addon"> |
| 273 |
<div class="ultp-content-addon-container"> |
| 274 |
<div class="ultp-content-meta"> |
| 275 |
<img src="<?php echo esc_url($val['img']); ?>" alt="<?php echo esc_attr($val['name']); ?>"> |
| 276 |
</div> |
| 277 |
<div class="ultp-addons-option-wrapper"> |
| 278 |
<div class="ultp-addons-option-control"> |
| 279 |
<span class="ultp-mid-title"><?php echo esc_html($val['name']); ?></span> |
| 280 |
<div class="ultp-control-option"> |
| 281 |
<?php |
| 282 |
if (isset($val['docs'])) { ?> |
| 283 |
<a href="<?php echo esc_url($val['docs']); ?>" class="ultp-option-tooltip" target="_blank"> |
| 284 |
<span><?php esc_html_e('Documentation', 'ultimate-post'); ?></span> |
| 285 |
<div class="dashicons dashicons-book"></div> |
| 286 |
</a> |
| 287 |
<?php } ?> |
| 288 |
|
| 289 |
<?php |
| 290 |
if (isset($val['live'])) { ?> |
| 291 |
<a href="<?php echo esc_url($val['live']); ?>" class="ultp-option-tooltip" target="_blank"> |
| 292 |
<span><?php esc_html_e('Live View', 'ultimate-post'); ?></span> |
| 293 |
<div class="dashicons dashicons-visibility"></div> |
| 294 |
</a> |
| 295 |
<?php } ?> |
| 296 |
|
| 297 |
<input type="checkbox" data-type="<?php echo esc_attr($key); ?>" class="ultp-addons-enable <?php echo (($val['is_pro'] && (!defined('ULTP_PRO_VER'))) ? 'disabled' : ''); ?>" id="<?php echo esc_attr($key); ?>" <?php echo ( isset($option_value[$key]) && $option_value[$key] == 'true' ? 'checked' : '' ); ?>/> |
| 298 |
<label for="<?php echo esc_attr($key); ?>"> |
| 299 |
<?php if ($val['is_pro'] && (!defined('ULTP_PRO_VER'))) { ?> |
| 300 |
<span class="dashicons dashicons-lock"></span> |
| 301 |
<?php } ?> |
| 302 |
</label> |
| 303 |
|
| 304 |
<?php |
| 305 |
if (isset($settings[$key])) { ?> |
| 306 |
<span class="ultp-block-settings dashicons dashicons-admin-generic"></span> |
| 307 |
<div class="ultp-popup-container blocks-settings"> |
| 308 |
<div class="ultp-unlock-popup"> |
| 309 |
<form action=""> |
| 310 |
<?php |
| 311 |
require_once ULTP_PATH.'classes/options/Settings.php'; |
| 312 |
$obj = new \ULTP\Option_Settings(); |
| 313 |
$obj->get_settings_data($settings[$key]['attr']); |
| 314 |
?> |
| 315 |
<div class="ultp-data-message"></div> |
| 316 |
<div> |
| 317 |
<button class="ultp-addons-setting-save"><?php esc_html_e('Save Settings', 'ultimate-post'); ?></button> |
| 318 |
</div> |
| 319 |
</form> |
| 320 |
<button class="ultp-popup-close"></button> |
| 321 |
</div> |
| 322 |
</div> |
| 323 |
<?php } ?> |
| 324 |
</div> |
| 325 |
</div> |
| 326 |
<div class="ultp-addon-desc ultp-addon-desc"><?php echo esc_html($val['desc']); ?></div> |
| 327 |
</div> |
| 328 |
</div> |
| 329 |
<?php if ($require_plugin) { ?> |
| 330 |
<div class="ultp-plugin-required"> |
| 331 |
<?php esc_html_e('This addon required this plugin:', 'ultimate-post'); ?> <b><?php echo wp_kses($require_plugin, 'post'); ?></b> |
| 332 |
</div> |
| 333 |
<?php } ?> |
| 334 |
</div> |
| 335 |
<?php } ?> |
| 336 |
</div> |
| 337 |
</div> |
| 338 |
</div> |
| 339 |
<?php } |
| 340 |
} |