| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
die; |
| 10 |
} // Cannot access directly. |
| 11 |
|
| 12 |
if ( ! class_exists( 'Module_Google_PagesSpeed' ) ) { |
| 13 |
class Module_Google_PagesSpeed extends AdminSettingsModel { |
| 14 |
|
| 15 |
public function __construct() { |
| 16 |
$this->google_pagepseed_settings(); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
public function get_defaults() { |
| 21 |
return [ |
| 22 |
'google_pagepseed_user_roles' => [], |
| 23 |
'google_pagepseed_api_key' => '', |
| 24 |
]; |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* Media Elements Sortable |
| 30 |
* |
| 31 |
* @return void |
| 32 |
*/ |
| 33 |
|
| 34 |
public function google_pagepseed_api_key( &$fields ) { |
| 35 |
$fields[] = [ |
| 36 |
'type' => 'subheading', |
| 37 |
'content' => Utils::adminfiy_help_urls( |
| 38 |
__( 'Google Pagespeed Settings', 'adminify' ), |
| 39 |
'https://wpadminify.com/kb/google-pagespeed-insights/', |
| 40 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 41 |
'https://www.facebook.com/groups/jeweltheme', |
| 42 |
'https://wpadminify.com/support/google-pagespeed-insights/' |
| 43 |
), |
| 44 |
]; |
| 45 |
|
| 46 |
$fields[] = [ |
| 47 |
'id' => 'google_pagepseed_user_roles', |
| 48 |
'type' => 'select', |
| 49 |
'title' => __( 'Disable for', 'adminify' ), |
| 50 |
'placeholder' => __( 'Select User roles you want to show', 'adminify' ), |
| 51 |
'options' => 'roles', |
| 52 |
'multiple' => true, |
| 53 |
'chosen' => true, |
| 54 |
'default' => $this->get_default_field( 'google_pagepseed_user_roles' ), |
| 55 |
]; |
| 56 |
|
| 57 |
$fields[] = [ |
| 58 |
'id' => 'google_pagepseed_api_key', |
| 59 |
'type' => 'textarea', |
| 60 |
'title' => __( 'Google API Key', 'adminify' ), |
| 61 |
'after' => sprintf( __( 'Don\'t have API key? Create one from <a href="%1$s" target="_blank">Google Console</a> to Unlock this feature. Read the full <a href="%2$s" target="_blank">Documentation</a>', 'adminify' ), esc_url( 'https://console.developers.google.com' ), esc_url( 'https://wpadminify.com/kb/how-to-create-google-api-key' ) ), |
| 62 |
'default' => $this->get_default_field( 'google_pagepseed_api_key' ), |
| 63 |
]; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
public function google_pagepseed_settings() { |
| 68 |
if ( ! class_exists( 'ADMINIFY' ) ) { |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
$fields = []; |
| 73 |
$this->google_pagepseed_api_key( $fields ); |
| 74 |
|
| 75 |
// Google PageSpeed Order Section |
| 76 |
\ADMINIFY::createSection( |
| 77 |
$this->prefix, |
| 78 |
[ |
| 79 |
'title' => __( 'Google PageSpeed', 'adminify' ), |
| 80 |
'id' => 'module_google_pagespeed_section', |
| 81 |
'parent' => 'module_settings', |
| 82 |
'icon' => 'fas fa-tachometer-alt', |
| 83 |
'fields' => $fields, |
| 84 |
] |
| 85 |
); |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|