| 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 |
} |
| 10 |
|
| 11 |
public static function all_addons() { |
| 12 |
$all_addons = array( |
| 13 |
'ultp_category' => array( |
| 14 |
'name' => __( 'Category', 'ultimate-post' ), |
| 15 |
'desc' => __( 'Choose your desired color and Image for categories or any taxonomy.', 'ultimate-post' ), |
| 16 |
'img' => ULTP_URL.'/assets/img/addons/category-style.svg', |
| 17 |
'is_pro' => true, |
| 18 |
'docs' => 'https://docs.wpxpo.com/docs/postx/', |
| 19 |
'live' => 'https://www.wpxpo.com/postx/addons/category/' |
| 20 |
), |
| 21 |
'ultp_builder' => array( |
| 22 |
'name' => __( 'Dynamic Site Builder', 'ultimate-post' ), |
| 23 |
'desc' => __( 'Create dynamic websites using the PostX instead of old-school page builders.', 'ultimate-post' ), |
| 24 |
'img' => ULTP_URL.'/assets/img/addons/builder-icon.svg', |
| 25 |
'is_pro' => true, |
| 26 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/archive-builder/', |
| 27 |
'live' => 'https://www.wpxpo.com/postx/addons/builder/' |
| 28 |
), |
| 29 |
'ultp_progressbar' => array( |
| 30 |
'name' => __( 'Progressbar', 'ultimate-post' ), |
| 31 |
'desc' => __( 'Let the users see a graphical indicator to know the reading progress of a blog post.', 'ultimate-post' ), |
| 32 |
'img' => ULTP_URL.'/assets/img/addons/progressbar.svg', |
| 33 |
'is_pro' => true, |
| 34 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/progress-bar/', |
| 35 |
'live' => 'https://www.wpxpo.com/postx/progress-bar/' |
| 36 |
), |
| 37 |
'ultp_yoast' => array( |
| 38 |
'name' => __( 'Yoast Meta', 'ultimate-post' ), |
| 39 |
'desc' => __( 'Show Yoast meta description in the excerpt.', 'ultimate-post' ), |
| 40 |
'img' => ULTP_URL.'/assets/img/addons/yoast.svg', |
| 41 |
'is_pro' => true, |
| 42 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 43 |
'live' => 'https://www.wpxpo.com/postx/addons/yoast/', |
| 44 |
'required' => array( |
| 45 |
'name' => 'Yoast', |
| 46 |
'slug' => 'wordpress-seo/wp-seo.php' |
| 47 |
) |
| 48 |
), |
| 49 |
'ultp_aioseo' => array( |
| 50 |
'name' => __( 'All in One SEO Meta', 'ultimate-post' ), |
| 51 |
'desc' => __( 'Show All in One SEO meta description in the excerpt.', 'ultimate-post' ), |
| 52 |
'img' => ULTP_URL.'/assets/img/addons/aioseo.svg', |
| 53 |
'is_pro' => true, |
| 54 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 55 |
'live' => 'https://www.wpxpo.com/postx/addons/all-in-one-seo-meta/', |
| 56 |
'required' => array( |
| 57 |
'name' => 'All in One SEO', |
| 58 |
'slug' => 'all-in-one-seo-pack/all_in_one_seo_pack.php' |
| 59 |
) |
| 60 |
), |
| 61 |
'ultp_rankmath' => array( |
| 62 |
'name' => __( 'RankMath Meta', 'ultimate-post' ), |
| 63 |
'desc' => __( 'Show RankMath meta description in the excerpt.', 'ultimate-post' ), |
| 64 |
'img' => ULTP_URL.'/assets/img/addons/rankmath.svg', |
| 65 |
'is_pro' => true, |
| 66 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 67 |
'live' => 'https://www.wpxpo.com/postx/addons/rankmath/', |
| 68 |
'required' => array( |
| 69 |
'name' => 'RankMath', |
| 70 |
'slug' => 'seo-by-rank-math/rank-math.php' |
| 71 |
) |
| 72 |
), |
| 73 |
'ultp_seopress' => array( |
| 74 |
'name' => __( 'SEOPress Meta', 'ultimate-post' ), |
| 75 |
'desc' => __( 'Show SEOPress meta description in the excerpt.', 'ultimate-post' ), |
| 76 |
'img' => ULTP_URL.'/assets/img/addons/seopress.svg', |
| 77 |
'is_pro' => true, |
| 78 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 79 |
'live' => 'https://www.wpxpo.com/postx/addons/seopress/', |
| 80 |
'required' => array( |
| 81 |
'name' => 'SEOPress', |
| 82 |
'slug' => 'wp-seopress/seopress.php' |
| 83 |
) |
| 84 |
), |
| 85 |
'ultp_squirrly' => array( |
| 86 |
'name' => __( 'Squirrly Meta', 'ultimate-post' ), |
| 87 |
'desc' => __( 'Show Squirrly meta description in the excerpt.', 'ultimate-post' ), |
| 88 |
'img' => ULTP_URL.'/assets/img/addons/squirrly.svg', |
| 89 |
'is_pro' => true, |
| 90 |
'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/', |
| 91 |
'live' => 'https://www.wpxpo.com/postx/addons/squirrly/', |
| 92 |
'required' => array( |
| 93 |
'name' => 'Squirrly', |
| 94 |
'slug' => 'squirrly-seo/squirrly.php' |
| 95 |
), |
| 96 |
), |
| 97 |
); |
| 98 |
return apply_filters('ultp_addons_config', $all_addons); |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
/** |
| 103 |
* Settings page output |
| 104 |
*/ |
| 105 |
public function create_admin_page() { ?> |
| 106 |
|
| 107 |
<div class="ultp-dashboard-container"> |
| 108 |
|
| 109 |
<!-- addons content --> |
| 110 |
<div class="ultp-dashboard-body ultp-addons-content"> |
| 111 |
|
| 112 |
<!-- Pro Popup Container --> |
| 113 |
<?php ultimate_post()->pro_popup_html(); ?> |
| 114 |
|
| 115 |
<h3 class="ultp-md-heading ultp-mb25"> |
| 116 |
<?php _e('All Addons', 'ultimate-post'); ?> |
| 117 |
</h3> |
| 118 |
|
| 119 |
<div class="ultp-addons-grid"> |
| 120 |
<?php |
| 121 |
$settings = apply_filters('ultp_settings', []); |
| 122 |
$option_value = ultimate_post()->get_setting(); |
| 123 |
$addons_data = self::all_addons(); |
| 124 |
foreach ($addons_data as $key => $val) { |
| 125 |
$require_plugin = ''; |
| 126 |
if (isset($val['required'])) { |
| 127 |
$active_plugins = get_option( 'active_plugins', array() ); |
| 128 |
if (is_multisite()) { |
| 129 |
$active_plugins = array_merge($active_plugins, array_keys(get_site_option( 'active_sitewide_plugins', array() ))); |
| 130 |
} |
| 131 |
if ( !in_array($val['required']['slug'], apply_filters('active_plugins', $active_plugins)) ) { |
| 132 |
$require_plugin = $val['required']['name']; |
| 133 |
} |
| 134 |
} |
| 135 |
?> |
| 136 |
<div class="ultp-content-addon ultp-card ultp-p25"> |
| 137 |
<div class="ultp-content-addon-container"> |
| 138 |
<div class="ultp-content-meta"> |
| 139 |
<img src="<?php echo esc_url($val['img']); ?>" alt="<?php echo esc_attr($val['name']); ?>"> |
| 140 |
</div> |
| 141 |
<div class="ultp-addons-option-wrapper"> |
| 142 |
<div class="ultp-addons-option-control"> |
| 143 |
<h4 class="ultp-xs-heading"><?php echo esc_html($val['name']); ?></h4> |
| 144 |
<div class="ultp-control-option"> |
| 145 |
<?php |
| 146 |
if (isset($val['docs'])) { ?> |
| 147 |
<a href="<?php echo esc_url($val['docs']); ?>" class="ultp-option-tooltip" target="_blank"> |
| 148 |
<span><?php esc_html_e('Documentation', 'ultimate-post'); ?></span> |
| 149 |
<div class="dashicons dashicons-book"></div> |
| 150 |
</a> |
| 151 |
<?php } ?> |
| 152 |
|
| 153 |
<?php |
| 154 |
if (isset($val['live'])) { ?> |
| 155 |
<a href="<?php echo esc_url($val['live']); ?>" class="ultp-option-tooltip" target="_blank"> |
| 156 |
<span><?php esc_html_e('Live View', 'ultimate-post'); ?></span> |
| 157 |
<div class="dashicons dashicons-visibility"></div> |
| 158 |
</a> |
| 159 |
<?php } ?> |
| 160 |
|
| 161 |
<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' : '' ); ?>/> |
| 162 |
<label for="<?php echo esc_attr($key); ?>" class="ultp-control__label"> |
| 163 |
<?php if ($val['is_pro'] && (!defined('ULTP_PRO_VER'))) { ?> |
| 164 |
<span class="dashicons dashicons-lock"></span> |
| 165 |
<?php } ?> |
| 166 |
</label> |
| 167 |
|
| 168 |
<?php |
| 169 |
if (isset($settings[$key])) { ?> |
| 170 |
<span class="ultp-block-settings dashicons dashicons-admin-generic"></span> |
| 171 |
<div class="ultp-popup-container blocks-settings"> |
| 172 |
<div class="ultp-unlock-popup"> |
| 173 |
<form action=""> |
| 174 |
<?php |
| 175 |
require_once ULTP_PATH.'classes/options/Settings.php'; |
| 176 |
$obj = new \ULTP\Option_Settings(); |
| 177 |
$obj->get_settings_data($settings[$key]['attr']); |
| 178 |
?> |
| 179 |
<div class="ultp-data-message"></div> |
| 180 |
<div> |
| 181 |
<button class="ultp-addons-setting-save"><?php esc_html_e('Save Settings', 'ultimate-post'); ?></button> |
| 182 |
</div> |
| 183 |
</form> |
| 184 |
<button class="ultp-popup-close"></button> |
| 185 |
</div> |
| 186 |
</div> |
| 187 |
<?php } ?> |
| 188 |
</div> |
| 189 |
</div> |
| 190 |
<div class="ultp-addon-desc ultp-sm-text"><?php echo esc_html($val['desc']); ?></div> |
| 191 |
</div> |
| 192 |
</div> |
| 193 |
<?php if ($require_plugin) { ?> |
| 194 |
<div class="ultp-plugin-required"> |
| 195 |
<?php esc_html_e('This addon required this plugin:', 'ultimate-post'); ?> <b><?php echo wp_kses($require_plugin, 'post'); ?></b> |
| 196 |
</div> |
| 197 |
<?php } ?> |
| 198 |
</div> |
| 199 |
<?php } ?> |
| 200 |
</div> |
| 201 |
</div> |
| 202 |
</div> |
| 203 |
<?php } |
| 204 |
} |