plugins.php
725 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Wpmet\Libs; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | if( !class_exists('\ShopEngine\Wpmet\Libs\Plugins') ) { |
| 8 | |
| 9 | /** |
| 10 | * Description: Wpmet Apps class. This class is used to display the wpmet other plugins |
| 11 | * |
| 12 | * @package Wpmet\UtilityPackage |
| 13 | * @subpackage Wpmet\UtilityPackage\Apps |
| 14 | * @author Wpmet |
| 15 | * |
| 16 | * @since 1.0.0 |
| 17 | */ |
| 18 | class Plugins { |
| 19 | |
| 20 | private static $instance; |
| 21 | private $text_domain; |
| 22 | private $parent_menu_slug; |
| 23 | private $menu_slug = '_wpmet_plugins'; |
| 24 | private $submenu_name = 'Our Plugins'; |
| 25 | private $plugins = []; |
| 26 | public $items_per_row = 4; |
| 27 | private $section_title = 'Take your website to the next level'; |
| 28 | private $section_description = 'We have some plugins you can install to get most from Wordpress. These are absolute FREE to use.'; |
| 29 | private $installed_plugins = []; |
| 30 | private $activated_plugins = []; |
| 31 | /** |
| 32 | * Creates and returns an instance of the class. |
| 33 | * |
| 34 | * @return self |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | */ |
| 38 | public static function instance() { |
| 39 | |
| 40 | if ( !self::$instance ) { |
| 41 | self::$instance = new self(); |
| 42 | } |
| 43 | |
| 44 | return self::$instance; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Initializes the function. |
| 49 | * |
| 50 | * @param string $text_domain The text domain. |
| 51 | * @return $this |
| 52 | * |
| 53 | * @since 1.0.0 |
| 54 | */ |
| 55 | public function init( $text_domain ) { |
| 56 | |
| 57 | $this->set_text_domain( $text_domain ); |
| 58 | $this->collect_installed_plugins(); |
| 59 | $this->collect_activated_plugins(); |
| 60 | |
| 61 | add_action('admin_head', [$this, 'enqueue_scripts']); |
| 62 | |
| 63 | return $this; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Set the section title. |
| 68 | * |
| 69 | * @param string $title The title of the section. |
| 70 | * @return $this The current object instance. |
| 71 | * |
| 72 | * @since 1.0.0 |
| 73 | */ |
| 74 | public function set_section_title( $title ){ |
| 75 | |
| 76 | $this->section_title = $title; |
| 77 | |
| 78 | return $this; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Sets the description for the section. |
| 83 | * |
| 84 | * @param mixed $description The description for the section. |
| 85 | * @return $this |
| 86 | * |
| 87 | * @since 1.0.0 |
| 88 | */ |
| 89 | public function set_section_description( $description ){ |
| 90 | |
| 91 | $this->section_description = $description; |
| 92 | |
| 93 | return $this; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Sets the number of items per row. |
| 98 | * |
| 99 | * @param int $items The number of items per row. |
| 100 | * @return $this The current object instance. |
| 101 | * |
| 102 | * @since 1.0.0 |
| 103 | */ |
| 104 | public function set_items_per_row( $items ){ |
| 105 | |
| 106 | $this->items_per_row = $items; |
| 107 | |
| 108 | return $this; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Set the text domain for the object. |
| 113 | * |
| 114 | * @param mixed $val The value to set as the text domain. |
| 115 | * @return $this The current object instance. |
| 116 | * |
| 117 | * @since 1.0.0 |
| 118 | */ |
| 119 | protected function set_text_domain( $val ) { |
| 120 | |
| 121 | $this->text_domain = $val; |
| 122 | |
| 123 | return $this; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Sets the submenu name. |
| 128 | * |
| 129 | * @param string $submenu_name The name of the submenu. |
| 130 | * @return $this The current instance of the class. |
| 131 | * |
| 132 | * @since 1.0.0 |
| 133 | */ |
| 134 | public function set_submenu_name( $submenu_name ){ |
| 135 | |
| 136 | $this->submenu_name = $submenu_name; |
| 137 | |
| 138 | return $this; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Set the parent menu slug. |
| 143 | * |
| 144 | * @param string $slug The slug of the parent menu. |
| 145 | * @return $this The current object. |
| 146 | */ |
| 147 | public function set_parent_menu_slug( $slug ) { |
| 148 | |
| 149 | $this->parent_menu_slug = $slug; |
| 150 | |
| 151 | return $this; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Sets the menu slug for the object. |
| 156 | * |
| 157 | * @param string $slug The slug to set for the menu. |
| 158 | * @return $this Returns the current object. |
| 159 | * |
| 160 | * @since 1.0.0 |
| 161 | */ |
| 162 | public function set_menu_slug( $slug ) { |
| 163 | |
| 164 | $this->menu_slug = $slug; |
| 165 | |
| 166 | return $this; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Set the plugins for the object. |
| 171 | * |
| 172 | * @param array $plugins An array of plugins. |
| 173 | * @return $this The current instance. |
| 174 | * |
| 175 | * @since 1.0.0 |
| 176 | */ |
| 177 | public function set_plugins( $plugins = [] ) { |
| 178 | |
| 179 | $this->plugins = $plugins; |
| 180 | |
| 181 | return $this; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Registers a menu in the WordPress admin dashboard. |
| 186 | * |
| 187 | * @return void |
| 188 | * |
| 189 | * @since 1.0.0 |
| 190 | */ |
| 191 | protected function register_menu() { |
| 192 | |
| 193 | add_submenu_page( |
| 194 | $this->parent_menu_slug, |
| 195 | $this->submenu_name, |
| 196 | '<span style="color: #2fbf17; font-weight: bold">' . $this->submenu_name . '</span>', |
| 197 | 'manage_options', |
| 198 | $this->text_domain . $this->menu_slug, |
| 199 | [$this, 'wpmet_apps_renderer'] |
| 200 | ); |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Generates the menus. |
| 205 | * |
| 206 | * @return void |
| 207 | * |
| 208 | * @since 1.0.0 |
| 209 | */ |
| 210 | public function generate_menus() { |
| 211 | |
| 212 | if( !empty($this->parent_menu_slug) ) { |
| 213 | |
| 214 | $this->register_menu(); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Admin menu registration hook. |
| 220 | * |
| 221 | * @return void |
| 222 | * |
| 223 | * @since 1.0.0 |
| 224 | */ |
| 225 | public function call() { |
| 226 | |
| 227 | add_action('admin_menu', [$this, 'generate_menus'], 99999); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Activation URL |
| 232 | * |
| 233 | * @since 1.0.0 |
| 234 | * @param string $pluginName The name of the plugin. |
| 235 | * @return string |
| 236 | */ |
| 237 | public function activation_url( $pluginName ) { |
| 238 | |
| 239 | return wp_nonce_url( add_query_arg( |
| 240 | array( |
| 241 | 'action' => 'activate', |
| 242 | 'plugin' => $pluginName, |
| 243 | 'plugin_status' => 'all', |
| 244 | 'paged' => '1&s', |
| 245 | ), |
| 246 | admin_url( 'plugins.php' ) |
| 247 | ), 'activate-plugin_' . $pluginName ); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Installation URL |
| 252 | * |
| 253 | * @since 1.0.0 |
| 254 | * @param string $pluginName The name of the plugin. |
| 255 | * @return string |
| 256 | */ |
| 257 | public function installation_url( $pluginName ) { |
| 258 | $action = 'install-plugin'; |
| 259 | $pluginSlug = $this->get_plugin_slug( $pluginName ); |
| 260 | |
| 261 | return wp_nonce_url( |
| 262 | add_query_arg( |
| 263 | array( |
| 264 | 'action' => $action, |
| 265 | 'plugin' => $pluginSlug |
| 266 | ), |
| 267 | admin_url( 'update.php' ) |
| 268 | ), |
| 269 | $action . '_' . $pluginSlug |
| 270 | ); |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Get plugin slug |
| 275 | * |
| 276 | * @since 1.0.0 |
| 277 | * @param string $name The name of the plugin. |
| 278 | * @return string |
| 279 | */ |
| 280 | public function get_plugin_slug( $name ) { |
| 281 | |
| 282 | $split = explode( '/', $name ); |
| 283 | |
| 284 | return isset( $split[0] ) ? $split[0] : null; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Activated URL |
| 289 | * |
| 290 | * @since 1.0.0 |
| 291 | * @param string $pluginName The name of the plugin. |
| 292 | * @return string |
| 293 | */ |
| 294 | public function activated_url( $pluginName ) { |
| 295 | return add_query_arg( |
| 296 | array( |
| 297 | 'page' => $this->get_plugin_slug( $pluginName ), |
| 298 | ), |
| 299 | admin_url( 'admin.php' ) ); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Collect installed plugins |
| 304 | * |
| 305 | * @since 1.0.0 |
| 306 | * @return void |
| 307 | */ |
| 308 | private function collect_installed_plugins() { |
| 309 | |
| 310 | if( !function_exists('get_plugins') ) { |
| 311 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 312 | } |
| 313 | |
| 314 | foreach ( get_plugins() as $key => $plugin ) { |
| 315 | array_push( $this->installed_plugins, $key ); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Collect activated plugins |
| 321 | * |
| 322 | * @since 1.0.0 |
| 323 | * @return void |
| 324 | */ |
| 325 | private function collect_activated_plugins() { |
| 326 | foreach ( apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) as $plugin ) { |
| 327 | array_push( $this->activated_plugins, $plugin ); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Check installed plugin |
| 333 | * |
| 334 | * @since 1.0.0 |
| 335 | * @param string $name The name of the plugin. |
| 336 | * @return bool |
| 337 | */ |
| 338 | public function check_installed_plugin( $name ) { |
| 339 | return in_array( $name, $this->installed_plugins ); |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Check activated plugin |
| 344 | * |
| 345 | * @since 1.0.0 |
| 346 | * @param string $name The name of the plugin. |
| 347 | * @return bool |
| 348 | */ |
| 349 | public function check_activated_plugin( $name ) { |
| 350 | return in_array( $name, $this->activated_plugins ); |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Get plugin status |
| 355 | * |
| 356 | * @since 1.0.0 |
| 357 | * @param string $name The name of the plugin. |
| 358 | * @return array |
| 359 | */ |
| 360 | public function get_plugin_status( $name ) { |
| 361 | $data = [ |
| 362 | "url" => "", |
| 363 | "activation_url" => "", |
| 364 | "installation_url" => "", |
| 365 | "title" => "", |
| 366 | "status" => "", |
| 367 | ]; |
| 368 | |
| 369 | if ( $this->check_installed_plugin( $name ) ) { |
| 370 | if ( $this->check_activated_plugin( $name ) ) { |
| 371 | $data['title'] = __( 'Activated', 'shopengine' ); |
| 372 | $data['status'] = "activated"; |
| 373 | } else { |
| 374 | $data['title'] = __( 'Activate Now', 'shopengine' ); |
| 375 | $data['status'] = 'installed'; |
| 376 | $data['activation_url'] = $this->activation_url( $name ); |
| 377 | } |
| 378 | } else { |
| 379 | $data['title'] = __( 'Install Now', 'shopengine' ); |
| 380 | $data['status'] = 'not_installed'; |
| 381 | $data['installation_url'] = $this->installation_url( $name ); |
| 382 | $data['activation_url'] = $this->activation_url( $name ); |
| 383 | } |
| 384 | |
| 385 | return $data; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Display the Wpmet apps section. |
| 390 | * |
| 391 | * @return void |
| 392 | * |
| 393 | * @since 1.0.0 |
| 394 | */ |
| 395 | public function wpmet_apps_renderer() { |
| 396 | ?> |
| 397 | <div class="wpmet-onboard-dashboard"> |
| 398 | <div class="wpmet-onboard-main-header"> |
| 399 | <h1 class="wpmet-onboard-main-header--title"><strong><?php echo esc_html($this->section_title); ?></strong></h1> |
| 400 | <p class="wpmet-onboard-main-header--description"><?php echo esc_html($this->section_description); ?></p> |
| 401 | </div> |
| 402 | |
| 403 | <div class="wpmet-onboard-plugin-list"> |
| 404 | <div class="attr-row"> |
| 405 | <?php |
| 406 | foreach( $this->plugins as $key => $plugin ): |
| 407 | $img_url = isset($plugin['icon']) ? $plugin['icon'] : '#'; |
| 408 | $plugin_name = isset($plugin['name']) ? $plugin['name'] : ''; |
| 409 | $plugin_desc = isset($plugin['desc']) ? $plugin['desc'] : ''; |
| 410 | $plugin_docs = isset($plugin['docs']) ? $plugin['docs'] : ''; |
| 411 | ?> |
| 412 | <div class="attr-col-lg-4"> |
| 413 | <div class="wpmet-onboard-single-plugin"> |
| 414 | <label> |
| 415 | <img class="wpmet-onboard-single-plugin--logo" src="<?php echo esc_url($img_url); ?>" alt="<?php echo esc_attr($plugin_name);?>"> |
| 416 | <h4 class="wpmet-single-plugin--name"><?php echo esc_html($plugin_name); ?></h4> |
| 417 | <p class="wpmet-onboard-single-plugin--description"><?php echo esc_html($plugin_desc); ?></p> |
| 418 | <?php |
| 419 | $plugin_data = $this->get_plugin_status( $key ); |
| 420 | $plugin_status = isset( $plugin_data['status'] ) ? $plugin_data['status'] : ''; |
| 421 | $plugin_activation_url = isset( $plugin_data['activation_url'] ) ? $plugin_data['activation_url'] : ''; |
| 422 | $plugin_installation_url = isset( $plugin_data['installation_url'] ) ? $plugin_data['installation_url'] : ''; |
| 423 | $plugin_status_label = isset( $plugin_data['status'] ) ? ( $plugin_data['status'] == 'activated' ? 'activated' : '' ) : ''; |
| 424 | $plugin_status_title = isset( $plugin_data['title'] ) ? $plugin_data['title'] : esc_html__('Activate', 'shopengine'); |
| 425 | ?> |
| 426 | <div class="wpmet-apps-footer"> |
| 427 | <?php |
| 428 | echo sprintf( |
| 429 | '<a data-plugin_status="%1$s" data-activation_url="%2$s" href="%3$s" class="wpmet-pro-btn wpmet-onboard-single-plugin--install_plugin %4$s">%5$s</a>', |
| 430 | esc_attr($plugin_status), |
| 431 | esc_url($plugin_activation_url), |
| 432 | esc_url($plugin_installation_url), |
| 433 | esc_attr($plugin_status_label), |
| 434 | esc_html($plugin_status_title) |
| 435 | ); |
| 436 | |
| 437 | if( !empty($plugin_docs) ) : |
| 438 | echo sprintf( |
| 439 | '<a target="_blank" href="%1$s">%2$s</a>', |
| 440 | esc_url($plugin_docs), |
| 441 | esc_html__('Read Docs', 'shopengine') |
| 442 | ); |
| 443 | endif; |
| 444 | ?> |
| 445 | </div> |
| 446 | </label> |
| 447 | </div> |
| 448 | </div> |
| 449 | <?php endforeach; ?> |
| 450 | </div> |
| 451 | </div> |
| 452 | </div> |
| 453 | <?php |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Enqueues scripts for the plugin. |
| 458 | * |
| 459 | * This function is responsible for enqueueing the necessary JavaScript scripts for the plugin. |
| 460 | * |
| 461 | * @return void |
| 462 | * |
| 463 | * @since 1.0.0 |
| 464 | */ |
| 465 | public function enqueue_scripts(){ |
| 466 | ?> |
| 467 | <style> |
| 468 | .wpmet-onboard-dashboard .wpmet-onboard-plugin-list .attr-row { |
| 469 | margin-left: -11px; |
| 470 | margin-right: -11px; |
| 471 | display: -webkit-box; |
| 472 | display: grid; |
| 473 | gap: 5px; |
| 474 | grid-template-columns: repeat(<?php echo esc_attr($this->items_per_row); ?>, 1fr); |
| 475 | } |
| 476 | .wpmet-onboard-dashboard .wpmet-onboard-plugin-list .attr-row > div { |
| 477 | padding: 11px; |
| 478 | } |
| 479 | .wpmet-onboard-main-header{ |
| 480 | margin-bottom: 30px; |
| 481 | } |
| 482 | .wpmet-onboard-dashboard .wpmet-onboard-main-header--title{ |
| 483 | color: #021343; |
| 484 | font-size: 40px; |
| 485 | line-height: 54px; |
| 486 | font-weight: normal; |
| 487 | margin: 0 0 3px 0; |
| 488 | padding: 0; |
| 489 | } |
| 490 | .wpmet-onboard-dashboard .wpmet-onboard-main-header--title strong{ |
| 491 | font-weight: 700; |
| 492 | } |
| 493 | .wpmet-onboard-dashboard .wpmet-onboard-main-header--description{ |
| 494 | color: #5d5e65; |
| 495 | font-size: 16px; |
| 496 | line-height: 26px; |
| 497 | margin: 0; |
| 498 | } |
| 499 | [class^="attr"] { |
| 500 | -webkit-box-sizing: border-box; |
| 501 | box-sizing: border-box; |
| 502 | } |
| 503 | .wpmet-onboard-dashboard { |
| 504 | background-color: #F5F6F9; |
| 505 | margin-left: -20px; |
| 506 | padding: 30px; |
| 507 | position: absolute; |
| 508 | top: 0; |
| 509 | left: 0; |
| 510 | z-index: 1; |
| 511 | width: calc(100% + 20px); |
| 512 | -webkit-box-sizing: border-box; |
| 513 | box-sizing: border-box; |
| 514 | min-height: calc(100vh - 32px); |
| 515 | padding-top: 30px; |
| 516 | padding-bottom: 100px; |
| 517 | } |
| 518 | .wpmet-onboard-dashboard .wpmet-pro-btn { |
| 519 | color: #3E77FC; |
| 520 | font-size: 15px; |
| 521 | line-height: 18px; |
| 522 | background-color: transparent; |
| 523 | font-weight: 500; |
| 524 | border: 1.5px solid #3E77FC; |
| 525 | border-radius: 6px; |
| 526 | padding: 11px 32px; |
| 527 | -webkit-transition: all .4s; |
| 528 | transition: all .4s; |
| 529 | text-decoration: none; |
| 530 | display: inline-block; |
| 531 | } |
| 532 | .wpmet-onboard-dashboard .wpmet-pro-btn:hover { |
| 533 | background-color: #3E77FC; |
| 534 | color: #fff; |
| 535 | } |
| 536 | .wpmet-onboard-dashboard .wpmet-pro-btn:focus { |
| 537 | border-color: #3E77FC; |
| 538 | -webkit-box-shadow: none; |
| 539 | box-shadow: none; |
| 540 | } |
| 541 | .wpmet-onboard-dashboard .wpmet-pro-btn .icon { |
| 542 | position: relative; |
| 543 | top: 1px; |
| 544 | } |
| 545 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin { |
| 546 | background-color: #fff; |
| 547 | border-radius: 6px; |
| 548 | -webkit-box-shadow: 0 30px 50px rgba(0, 10, 36, 0.1); |
| 549 | box-shadow: 0 30px 50px rgba(0, 10, 36, 0.1); |
| 550 | position: relative; |
| 551 | min-height: 320px; |
| 552 | } |
| 553 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin label { |
| 554 | display: block; |
| 555 | padding: 30px 40px 36px 30px; |
| 556 | cursor: default; |
| 557 | } |
| 558 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin .badge--featured { |
| 559 | position: absolute; |
| 560 | right: -20px; |
| 561 | top: -30px; |
| 562 | height: 100px; |
| 563 | } |
| 564 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--install { |
| 565 | color: #021343; |
| 566 | font-size: 15px; |
| 567 | font-weight: 500; |
| 568 | display: block; |
| 569 | border: 2px solid #E4E6EE; |
| 570 | border-radius: 6px; |
| 571 | min-height: 175px; |
| 572 | line-height: 175px; |
| 573 | position: relative; |
| 574 | text-decoration: none; |
| 575 | } |
| 576 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--install i { |
| 577 | padding-left: 9px; |
| 578 | font-weight: bold; |
| 579 | } |
| 580 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--description { |
| 581 | color: #5D5E65; |
| 582 | font-size: 15px; |
| 583 | line-height: 22px; |
| 584 | font-weight: 400; |
| 585 | margin: 0; |
| 586 | } |
| 587 | .wpmet-onboard-dashboard .wpmet-single-plugin--name { |
| 588 | display: block; |
| 589 | font-size: 1.6rem; |
| 590 | line-height: normal; |
| 591 | text-decoration: none; |
| 592 | margin: 0px; |
| 593 | font-weight: 600; |
| 594 | color: #021343; |
| 595 | margin-top: 5px; |
| 596 | margin-bottom: 15px; |
| 597 | } |
| 598 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--description span { |
| 599 | background: #d7a1f973; |
| 600 | color: #021343; |
| 601 | font-weight: 500; |
| 602 | } |
| 603 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--logo { |
| 604 | max-width: 60px; |
| 605 | } |
| 606 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--install_plugin { |
| 607 | padding: 5px 20px 7px 20px; |
| 608 | } |
| 609 | .wpmet-onboard-dashboard .wpmet-apps-footer{ |
| 610 | position: absolute; |
| 611 | bottom: 30px; |
| 612 | width: 80%; |
| 613 | display: flex; |
| 614 | justify-content: space-between; |
| 615 | align-items: baseline; |
| 616 | background: #fff; |
| 617 | padding-top: 5px; |
| 618 | } |
| 619 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--install_plugin.wpmet-plugin-install-activate { |
| 620 | cursor: no-drop; |
| 621 | background-color: #E8E9EF; |
| 622 | color: #5D5E65; |
| 623 | border-color: #E8E9EF; |
| 624 | } |
| 625 | .wpmet-onboard-dashboard .wpmet-onboard-single-plugin--install_plugin.activated { |
| 626 | cursor: default; |
| 627 | border: 1px solid #2AAE1433; |
| 628 | background: rgba(42, 174, 20, 0.1); |
| 629 | color: #2AAE14; |
| 630 | } |
| 631 | .wpmet-onboard-dashboard .wpmet-onboard-tut-term--help { |
| 632 | margin: 0; |
| 633 | color: #021343; |
| 634 | font-size: 14px; |
| 635 | font-weight: 500; |
| 636 | line-height: 26px; |
| 637 | margin-top: 10px; |
| 638 | cursor: pointer; |
| 639 | } |
| 640 | .wpmet-onboard-dashboard .wpmet-onboard-tut-term--help:hover { |
| 641 | color: #3E77FC; |
| 642 | } |
| 643 | .wpmet-onboard-dashboard .wpmet-onboard-tut-term--help.active { |
| 644 | color: #3E77FC; |
| 645 | } |
| 646 | @media (max-width: 2000px) { |
| 647 | .wpmet-onboard-dashboard .wpmet-onboard-plugin-list .attr-row { |
| 648 | grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); |
| 649 | } |
| 650 | } |
| 651 | @media (max-width: 500px) { |
| 652 | .wpmet-onboard-dashboard .wpmet-onboard-plugin-list .attr-row { |
| 653 | grid-template-columns: repeat(auto-fit, minmax(100%, 1fr)); |
| 654 | } |
| 655 | } |
| 656 | @media (max-width: 991px) { |
| 657 | body .wpmet-onboard-dashboard img { |
| 658 | max-width: 100%; |
| 659 | } |
| 660 | } |
| 661 | @media (max-width: 480px) { |
| 662 | body .wpmet-onboard-dashboard .wpmet-onboard-single-plugin label { |
| 663 | -webkit-box-align: center; |
| 664 | -ms-flex-align: center; |
| 665 | align-items: center; |
| 666 | } |
| 667 | } |
| 668 | </style> |
| 669 | |
| 670 | <script type="text/javascript"> |
| 671 | jQuery( document ).ready( function( $ ) { |
| 672 | // installing plugin |
| 673 | function wpmet_install_active_plugin(ajaxurl, success_callback, beforeText, successText){ |
| 674 | $.ajax({ |
| 675 | type : "GET", |
| 676 | url : ajaxurl, |
| 677 | beforeSend: () => { |
| 678 | $(this).addClass('wpmet-plugin-install-activate'); |
| 679 | if(beforeText){ |
| 680 | $(this).html(beforeText); |
| 681 | } |
| 682 | }, |
| 683 | success: (response) => { |
| 684 | $(this).removeClass('wpmet-plugin-install-activate'); |
| 685 | |
| 686 | if(ajaxurl.indexOf('action=activate') >= 0){ |
| 687 | $(this).addClass('activated'); |
| 688 | } |
| 689 | |
| 690 | $(this).html(successText); |
| 691 | |
| 692 | if(success_callback){success_callback();} |
| 693 | } |
| 694 | }); |
| 695 | } |
| 696 | |
| 697 | $('.wpmet-onboard-single-plugin--install_plugin').on('click', function(e){ |
| 698 | e.preventDefault(); |
| 699 | var installation_url = $(this).attr('href'), |
| 700 | activation_url = $(this).attr('data-activation_url'), |
| 701 | plugin_status = $(this).data('plugin_status'); |
| 702 | |
| 703 | if($(this).hasClass('wpmet-plugin-install-activate') || $(this).hasClass('activated')){ |
| 704 | return false; |
| 705 | } |
| 706 | |
| 707 | if(plugin_status == 'not_installed'){ |
| 708 | wpmet_install_active_plugin.call(this, installation_url, () => { |
| 709 | wpmet_install_active_plugin.call(this, activation_url, null, 'Activating...', 'Activated'); |
| 710 | }, 'Installing...', 'Installed'); |
| 711 | } else if (plugin_status == 'installed') { |
| 712 | wpmet_install_active_plugin.call(this, activation_url, null, 'Activating...', 'Activated'); |
| 713 | } |
| 714 | }); |
| 715 | |
| 716 | jQuery('.wpmet-onboard-tut-term--help').on('click', function(){ |
| 717 | $(this).toggleClass('active').prev().toggleClass('active'); |
| 718 | }); |
| 719 | |
| 720 | }); |
| 721 | </script> |
| 722 | <?php |
| 723 | } |
| 724 | } |
| 725 | } |