diff --git a/includes/admin/page-settings.php b/includes/admin/page-settings.php deleted file mode 100644 index 8608e4d..0000000 --- a/includes/admin/page-settings.php +++ /dev/null @@ -1,151 +0,0 @@ - -
-

-

Liveticker

-

' . __( 'Settings updated successfully.', 'wplt2' ) . '

'; - } ?> -
- -

- -

-
- - '; - echo ' '; - echo __( 'Enable', 'wplt2' ); - echo ''; - echo '

' . __( 'Disable this option to remove the default button styling and the Delightful Downloads CSS file.', 'wplt2' ) . '

'; -} - -/** - * Render default style field - * - * @return void - */ -function wplt_settings_default_style_field() { - global $wplt_options; - - $styles = wplt_get_shortcode_styles(); - $default_style = $wplt_options['default_style']; - - echo ''; - echo '

' . __( 'The default display style.', 'wplt2' ) . '

'; -} - -/** - * Render reset settings field - * - * @return void - */ -function wplt_settings_reset_settings_field() { - global $wplt_options; - - $checked = $wplt_options['reset_settings']; - - echo ''; -} \ No newline at end of file diff --git a/includes/class-wpliveticker2-admin.php b/includes/class-wpliveticker2-admin.php index aad9b88..6527220 100644 --- a/includes/class-wpliveticker2-admin.php +++ b/includes/class-wpliveticker2-admin.php @@ -25,8 +25,147 @@ class WPLiveticker2_Admin extends WPLiveticker2 { $total_files = wp_count_posts( 'wplt2_tick' ); echo ''; - echo '' . esc_html( $total_files->publish ) . ''; - echo '' . esc_html__( 'Ticks', 'wplt2' ) . ''; + echo '' . esc_html( $total_files->publish ) . ''; + echo '' . esc_html__( 'Ticks', 'wplt2' ) . ''; echo ''; } + + /** + * Register settings page. + * + * @return void + */ + public static function register_settings_page() { + add_submenu_page( + 'edit.php?post_type=wplt2_tick', + 'Liveticker2 ' . __( 'Settings', 'wplt2' ), + __( 'Settings', 'wplt2' ), + 'manage_options', + 'wplt2_settings', + array( + 'WPLiveticker2_Admin', + 'settings_page', + ) + ); + } + + /** + * Register settings API + * + * @return void + */ + public static function register_settings() { + register_setting( 'wplt2_settings', 'wplt2', array( 'WPLiveticker2_Admin', 'validate_settings' ) ); + + // Form sections. + add_settings_section( 'wplt2_settings_general', __( 'General', 'wplt2' ), array( 'WPLiveticker2_Admin', 'settings_general_section' ), __FILE__ ); + add_settings_section( 'wplt2_settings_uninstall', __( 'Uninstall', 'wplt2' ), array( 'WPLiveticker2_Admin', 'settings_uninstall_section' ), __FILE__ ); + + // Form fields. + add_settings_field( 'enable_css', __( 'Default CSS Styles', 'wplt2' ), array( 'WPLiveticker2_Admin', 'settings_enable_css_field' ), __FILE__, 'wplt2_settings_general' ); + add_settings_field( 'reset_settings', __( 'Reset Settings', 'wplt2' ), array( 'WPLiveticker2_Admin', 'settings_reset_settings_field' ), __FILE__, 'wplt2_settings_uninstall' ); + } + + /** + * Render general section. + * + * @return void + */ + public static function settings_general_section() { + } + + /** + * Render uninstall section. + * + * @return void + */ + public static function settings_uninstall_section() { + } + + /** + * Render enable css field. + * + * @return void + */ + public static function settings_enable_css_field() { + $checked = self::$_options['enable_css']; + + echo ''; + echo '

' . esc_html__( 'Disable this option to remove the default button styling and the Delightful Downloads CSS file.', 'wplt2' ) . '

'; + } + + /** + * Render default style field. + * + * @return void + */ + public static function settings_default_style_field() { + $styles = wplt_get_shortcode_styles(); + $default_style = self::$_options['default_style']; + + echo ''; + echo '

' . esc_html__( 'The default display style.', 'wplt2' ) . '

'; + } + + /** + * Render reset settings field + * + * @return void + */ + public static function settings_reset_settings_field() { + $checked = self::$_options['reset_settings']; + + echo ''; + } + + /** + * Render the settings page. + * + * @return void + */ + public static function settings_page() { + ?> +
+

+

Liveticker

+

' . esc_html__( 'Settings updated successfully.', 'wplt2' ) . '

'; +} ?> +
+ +

+ +

+
+ +