| 1 |
<?php |
| 2 |
namespace ULTP; |
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
class Options_Addons{ |
| 7 |
public function __construct() { |
| 8 |
add_submenu_page( |
| 9 |
'ultp-settings', |
| 10 |
__('Addons', 'ultimate-post'), |
| 11 |
__('Addons', 'ultimate-post'), |
| 12 |
'manage_options', |
| 13 |
'ultp-addons', |
| 14 |
array( $this, 'create_admin_page'), 10 |
| 15 |
); |
| 16 |
add_filter('ultp_settings', array($this, 'get_addon_settings'), 10, 1); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
public static function get_addon_settings($config) { |
| 21 |
$arr = array( |
| 22 |
'addon' => array( |
| 23 |
'label' => __('Blocks', 'ultimate-post'), |
| 24 |
'attr' => array( |
| 25 |
'addon_enable' => array( |
| 26 |
'type' => 'heading', |
| 27 |
'label' => __('Enable/Disable Blocks', 'ultimate-post'), |
| 28 |
), |
| 29 |
'post_grid_1' => array( |
| 30 |
'type' => 'switch', |
| 31 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 32 |
'default' => true, |
| 33 |
'desc' => __('Post Grid #1 Block.', 'ultimate-post') |
| 34 |
), |
| 35 |
'post_grid_2' => array( |
| 36 |
'type' => 'switch', |
| 37 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 38 |
'default' => true, |
| 39 |
'desc' => __('Post Grid #2 Block.', 'ultimate-post') |
| 40 |
), |
| 41 |
'post_grid_3' => array( |
| 42 |
'type' => 'switch', |
| 43 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 44 |
'default' => true, |
| 45 |
'desc' => __('Post Grid #3 Block.', 'ultimate-post') |
| 46 |
), |
| 47 |
'post_grid_4' => array( |
| 48 |
'type' => 'switch', |
| 49 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 50 |
'default' => true, |
| 51 |
'desc' => __('Post Grid #4 Block.', 'ultimate-post') |
| 52 |
), |
| 53 |
'post_grid_5' => array( |
| 54 |
'type' => 'switch', |
| 55 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 56 |
'default' => true, |
| 57 |
'desc' => __('Post Grid #5 Block.', 'ultimate-post') |
| 58 |
), |
| 59 |
'post_grid_6' => array( |
| 60 |
'type' => 'switch', |
| 61 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 62 |
'default' => true, |
| 63 |
'desc' => __('Post Grid #6 Block.', 'ultimate-post') |
| 64 |
), |
| 65 |
'post_grid_7' => array( |
| 66 |
'type' => 'switch', |
| 67 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 68 |
'default' => true, |
| 69 |
'desc' => __('Post Grid #7 Block.', 'ultimate-post') |
| 70 |
), |
| 71 |
'post_list_1' => array( |
| 72 |
'type' => 'switch', |
| 73 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 74 |
'default' => true, |
| 75 |
'desc' => __('Post List #1 Block.', 'ultimate-post') |
| 76 |
), |
| 77 |
'post_list_2' => array( |
| 78 |
'type' => 'switch', |
| 79 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 80 |
'default' => true, |
| 81 |
'desc' => __('Post List #2 Block.', 'ultimate-post') |
| 82 |
), |
| 83 |
'post_list_3' => array( |
| 84 |
'type' => 'switch', |
| 85 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 86 |
'default' => true, |
| 87 |
'desc' => __('Post List #3 Block.', 'ultimate-post') |
| 88 |
), |
| 89 |
'post_list_4' => array( |
| 90 |
'type' => 'switch', |
| 91 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 92 |
'default' => true, |
| 93 |
'desc' => __('Post List #4 Block.', 'ultimate-post') |
| 94 |
), |
| 95 |
'post_module_1' => array( |
| 96 |
'type' => 'switch', |
| 97 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 98 |
'default' => true, |
| 99 |
'desc' => __('Post Module #1 Block.', 'ultimate-post') |
| 100 |
), |
| 101 |
'post_module_2' => array( |
| 102 |
'type' => 'switch', |
| 103 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 104 |
'default' => true, |
| 105 |
'desc' => __('Post Module #2 Block.', 'ultimate-post') |
| 106 |
), |
| 107 |
'post_slider_1' => array( |
| 108 |
'type' => 'switch', |
| 109 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 110 |
'default' => true, |
| 111 |
'desc' => __('Post Slider #1 Block.', 'ultimate-post') |
| 112 |
), |
| 113 |
'heading' => array( |
| 114 |
'type' => 'switch', |
| 115 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 116 |
'default' => true, |
| 117 |
'desc' => __('Heading Block.', 'ultimate-post') |
| 118 |
), |
| 119 |
'image' => array( |
| 120 |
'type' => 'switch', |
| 121 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 122 |
'default' => true, |
| 123 |
'desc' => __('Image Block.', 'ultimate-post') |
| 124 |
), |
| 125 |
'taxonomy' => array( |
| 126 |
'type' => 'switch', |
| 127 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 128 |
'default' => true, |
| 129 |
'desc' => __('Taxonomy Block.', 'ultimate-post') |
| 130 |
), |
| 131 |
'wrapper' => array( |
| 132 |
'type' => 'switch', |
| 133 |
'label' => __('Enable / Disable', 'ultimate-post'), |
| 134 |
'default' => true, |
| 135 |
'desc' => __('Wrapper Block.', 'ultimate-post') |
| 136 |
) |
| 137 |
) |
| 138 |
) |
| 139 |
); |
| 140 |
return array_merge($config, $arr); |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
public static function all_addons(){ |
| 145 |
$all_addons = array( |
| 146 |
'ultp_category' => array( |
| 147 |
'name' => __( 'Category', 'ultimate-post' ), |
| 148 |
'desc' => __( 'Choose your desired color and Image for categories or any taxonomy.', 'ultimate-post' ), |
| 149 |
'img' => ULTP_URL.'/assets/img/addons/category-style.svg', |
| 150 |
'is_pro' => true |
| 151 |
), |
| 152 |
'ultp_builder' => array( |
| 153 |
'name' => __( 'Builder', 'ultimate-post' ), |
| 154 |
'desc' => __( 'Design template for Archive, Category, Custom Taxonomy, Date, and Search Page.', 'ultimate-post' ), |
| 155 |
'img' => ULTP_URL.'/assets/img/addons/builder-icon.svg', |
| 156 |
'is_pro' => true |
| 157 |
), |
| 158 |
'ultp_progressbar' => array( |
| 159 |
'name' => __( 'Progressbar', 'ultimate-post' ), |
| 160 |
'desc' => __( 'Let the users see a graphical indicator to know the reading progress of a blog post.', 'ultimate-post' ), |
| 161 |
'img' => ULTP_URL.'/assets/img/addons/progressbar.svg', |
| 162 |
'is_pro' => true |
| 163 |
), |
| 164 |
'ultp_yoast' => array( |
| 165 |
'name' => __( 'Yoast Meta', 'ultimate-post' ), |
| 166 |
'desc' => __( 'Show Yoast meta description in the excerpt.', 'ultimate-post' ), |
| 167 |
'img' => ULTP_URL.'/assets/img/addons/yoast.svg', |
| 168 |
'is_pro' => true, |
| 169 |
'required' => array( |
| 170 |
'name' => 'Yoast', |
| 171 |
'slug' => 'wordpress-seo/wp-seo.php' |
| 172 |
) |
| 173 |
), |
| 174 |
'ultp_aioseo' => array( |
| 175 |
'name' => __( 'All in One SEO Meta', 'ultimate-post' ), |
| 176 |
'desc' => __( 'Show All in One SEO meta description in the excerpt.', 'ultimate-post' ), |
| 177 |
'img' => ULTP_URL.'/assets/img/addons/aioseo.svg', |
| 178 |
'is_pro' => true, |
| 179 |
'required' => array( |
| 180 |
'name' => 'All in One SEO', |
| 181 |
'slug' => 'all-in-one-seo-pack/all_in_one_seo_pack.php' |
| 182 |
) |
| 183 |
), |
| 184 |
'ultp_rankmath' => array( |
| 185 |
'name' => __( 'RankMath Meta', 'ultimate-post' ), |
| 186 |
'desc' => __( 'Show RankMath meta description in the excerpt.', 'ultimate-post' ), |
| 187 |
'img' => ULTP_URL.'/assets/img/addons/rankmath.svg', |
| 188 |
'is_pro' => true, |
| 189 |
'required' => array( |
| 190 |
'name' => 'RankMath', |
| 191 |
'slug' => 'seo-by-rank-math/rank-math.php' |
| 192 |
) |
| 193 |
), |
| 194 |
'ultp_seopress' => array( |
| 195 |
'name' => __( 'SEOPress Meta', 'ultimate-post' ), |
| 196 |
'desc' => __( 'Show SEOPress meta description in the excerpt.', 'ultimate-post' ), |
| 197 |
'img' => ULTP_URL.'/assets/img/addons/seopress.svg', |
| 198 |
'is_pro' => true, |
| 199 |
'required' => array( |
| 200 |
'name' => 'SEOPress', |
| 201 |
'slug' => 'wp-seopress/seopress.php' |
| 202 |
) |
| 203 |
), |
| 204 |
'ultp_squirrly' => array( |
| 205 |
'name' => __( 'Squirrly Meta', 'ultimate-post' ), |
| 206 |
'desc' => __( 'Show Squirrly meta description in the excerpt.', 'ultimate-post' ), |
| 207 |
'img' => ULTP_URL.'/assets/img/addons/squirrly.svg', |
| 208 |
'is_pro' => true, |
| 209 |
'required' => array( |
| 210 |
'name' => 'Squirrly', |
| 211 |
'slug' => 'squirrly-seo/squirrly.php' |
| 212 |
), |
| 213 |
), |
| 214 |
); |
| 215 |
return apply_filters('ultp_addons_config', $all_addons); |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* Settings page output |
| 220 |
*/ |
| 221 |
public function create_admin_page() { ?> |
| 222 |
<style> |
| 223 |
.style-css{ |
| 224 |
background-color: #f2f2f2; |
| 225 |
-webkit-font-smoothing: subpixel-antialiased; |
| 226 |
} |
| 227 |
</style> |
| 228 |
|
| 229 |
<div class="ultp-option-body"> |
| 230 |
|
| 231 |
<?php require_once ULTP_PATH . 'classes/options/Heading.php'; ?> |
| 232 |
|
| 233 |
<div class="ultp-content-wrap ultp-addons-wrap"> |
| 234 |
<div class="ultp-text-center"><h2 class="ultp-admin-title"><?php _e('All Addons', 'ultimate-post'); ?></h2></div> |
| 235 |
<div class="ultp-addons-items"> |
| 236 |
<?php |
| 237 |
$option_value = ultimate_post()->get_setting(); |
| 238 |
$addons_data = self::all_addons(); |
| 239 |
foreach ($addons_data as $key => $val) { |
| 240 |
$require_plugin = ''; |
| 241 |
if (isset($val['required'])) { |
| 242 |
$active_plugins = get_option( 'active_plugins', array() ); |
| 243 |
if (is_multisite()) { |
| 244 |
$active_plugins = array_merge($active_plugins, array_keys(get_site_option( 'active_sitewide_plugins', array() ))); |
| 245 |
} |
| 246 |
if ( !in_array($val['required']['slug'], apply_filters('active_plugins', $active_plugins)) ) { |
| 247 |
$require_plugin = $val['required']['name']; |
| 248 |
} |
| 249 |
} |
| 250 |
echo '<div class="ultp-addons-item ultp-admin-card">'; |
| 251 |
echo '<div class="ultp-addons-item-content">'; |
| 252 |
echo '<img src="'.$val['img'].'" />'; |
| 253 |
echo '<h4>'.$val['name'].'</h4>'; |
| 254 |
echo '<div class="ultp-addons-desc">'.$val['desc'].'</div>'; |
| 255 |
echo '</div>'; |
| 256 |
if( $val['is_pro'] && !defined('ULTP_PRO_VER') ){ |
| 257 |
echo '<div class="ultp-addons-btn">'; |
| 258 |
echo '<a class="ultp-btn ultp-btn-default" target="_blank" href="'.ultimate_post()->get_premium_link().'">'.__("Get Pro", "ultimate-post").'</a>'; |
| 259 |
echo '</div>'; |
| 260 |
} else if ($require_plugin) { |
| 261 |
echo '<div class="ultp-addons-btn">'; |
| 262 |
echo __('This addon required ').'<b>'.$require_plugin.'</b>'; |
| 263 |
echo '</div>'; |
| 264 |
} else { |
| 265 |
echo '<div class="ultp-addons-btn">'; |
| 266 |
echo '<label class="ultp-switch">'; |
| 267 |
echo '<input class="ultp-addons-enable" '.(($val['is_pro'] && (!defined('ULTP_PRO_VER'))) ? 'disabled' : '').' data-addon="'.$key.'" type="checkbox" '.( isset($option_value[$key]) && $option_value[$key] == 'true' ? 'checked' : '' ).'>'; |
| 268 |
echo '<span class="ultp-slider ultp-round"></span>'; |
| 269 |
echo '</label>'; |
| 270 |
echo '</div>'; |
| 271 |
} |
| 272 |
echo '</div>'; |
| 273 |
} |
| 274 |
?> |
| 275 |
</div> |
| 276 |
</div> |
| 277 |
</div> |
| 278 |
|
| 279 |
<?php } |
| 280 |
} |