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