| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH' ) or die('No direct access'); |
| 4 |
|
| 5 |
class Pushly_Admin |
| 6 |
{ |
| 7 |
public static function init() |
| 8 |
{ |
| 9 |
$self = new self(); |
| 10 |
|
| 11 |
add_action('admin_menu', array(__CLASS__, 'add_settings_page')); |
| 12 |
add_action('admin_init', array(__CLASS__, 'init_settings')); |
| 13 |
|
| 14 |
return $self; |
| 15 |
} |
| 16 |
|
| 17 |
public static function add_settings_page() |
| 18 |
{ |
| 19 |
add_menu_page( |
| 20 |
'Pushly', |
| 21 |
'Pushly', |
| 22 |
'manage_options', |
| 23 |
'pushly', |
| 24 |
array(__CLASS__, 'settings_menu_html') |
| 25 |
); |
| 26 |
} |
| 27 |
|
| 28 |
public static function settings_menu_html() |
| 29 |
{ |
| 30 |
if (! current_user_can('manage_options')) { |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
if (isset($_GET['settings-updated'])) { |
| 35 |
add_settings_error('pushly_messages', 'pushly_message', __('Settings Saved', 'pushly' ), 'updated' ); |
| 36 |
} |
| 37 |
|
| 38 |
require_once PUSHLY_PLUGIN_PATH_ROOT . 'views/templates/settings.php'; |
| 39 |
} |
| 40 |
|
| 41 |
public static function init_settings() |
| 42 |
{ |
| 43 |
register_setting('pushly', 'pushly_options'); |
| 44 |
|
| 45 |
add_settings_section( |
| 46 |
'pushly_section_settings', |
| 47 |
__('Settings', 'pushly'), |
| 48 |
null, |
| 49 |
'pushly' |
| 50 |
); |
| 51 |
|
| 52 |
add_settings_field( |
| 53 |
'pushly_domain_key', |
| 54 |
__('Domain Key', 'pushly'), |
| 55 |
array(__CLASS__, 'field_domain_key'), |
| 56 |
'pushly', |
| 57 |
'pushly_section_settings', |
| 58 |
array( |
| 59 |
'label_for' => 'pushly_domain_key', |
| 60 |
) |
| 61 |
); |
| 62 |
} |
| 63 |
|
| 64 |
public static function field_domain_key($args) |
| 65 |
{ |
| 66 |
$options = get_option('pushly_options'); |
| 67 |
require_once PUSHLY_PLUGIN_PATH_ROOT . 'views/fields/domain_key.php'; |
| 68 |
} |
| 69 |
} |
| 70 |
|