| 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 |
{ |
| 17 |
$this->google_pagepseed_settings(); |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
public function get_defaults() |
| 22 |
{ |
| 23 |
return [ |
| 24 |
'google_pagepseed_user_roles' => [], |
| 25 |
'google_pagepseed_api_key' => '' |
| 26 |
]; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* Media Elements Sortable |
| 32 |
* |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
|
| 36 |
public function google_pagepseed_api_key(&$fields) |
| 37 |
{ |
| 38 |
$fields[] = array( |
| 39 |
'type' => 'subheading', |
| 40 |
'content' => Utils::adminfiy_help_urls( |
| 41 |
__('Google Pagespeed Settings', 'adminify'), |
| 42 |
'https://wpadminify.com/kb/google-pagespeed-insights/', |
| 43 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 44 |
'https://www.facebook.com/groups/jeweltheme', |
| 45 |
'https://wpadminify.com/support/google-pagespeed-insights/' |
| 46 |
) |
| 47 |
); |
| 48 |
|
| 49 |
$fields[] = array( |
| 50 |
'id' => 'google_pagepseed_user_roles', |
| 51 |
'type' => 'select', |
| 52 |
'title' => 'Disable for', |
| 53 |
'placeholder' => 'Select User roles you want to show', |
| 54 |
'options' => 'roles', |
| 55 |
'multiple' => true, |
| 56 |
'chosen' => true, |
| 57 |
'default' => $this->get_default_field('google_pagepseed_user_roles'), |
| 58 |
); |
| 59 |
|
| 60 |
$fields[] = array( |
| 61 |
'id' => 'google_pagepseed_api_key', |
| 62 |
'type' => 'textarea', |
| 63 |
'title' => 'Google API Key', |
| 64 |
'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')), |
| 65 |
'default' => $this->get_default_field('google_pagepseed_api_key'), |
| 66 |
); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
public function google_pagepseed_settings() |
| 71 |
{ |
| 72 |
|
| 73 |
if (!class_exists('ADMINIFY')) { |
| 74 |
return; |
| 75 |
} |
| 76 |
|
| 77 |
$fields = []; |
| 78 |
$this->google_pagepseed_api_key($fields); |
| 79 |
|
| 80 |
// Google PageSpeed Order Section |
| 81 |
\ADMINIFY::createSection($this->prefix, array( |
| 82 |
'title' => __('Google PageSpeed', 'adminify'), |
| 83 |
'id' => 'module_google_pagespeed_section', |
| 84 |
'parent' => 'module_settings', |
| 85 |
'icon' => 'fas fa-tachometer-alt', |
| 86 |
'fields' => $fields |
| 87 |
)); |
| 88 |
} |
| 89 |
} |
| 90 |
} |
| 91 |
|