From 32e6db17a0870d22429856495bc118db54f865ac Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Thu, 7 Dec 2017 18:22:21 +0100 Subject: [PATCH] Settings page restored, AJAX hook bundled in main class --- includes/ajax.php | 48 ---------------------- includes/class-wpliveticker2-admin.php | 53 ++++++++++++++++++++----- includes/class-wpliveticker2-widget.php | 2 +- includes/class-wpliveticker2.php | 49 +++++++++++++++++++++++ views/settings-page.php | 6 +-- views/widget-form.php | 2 +- wp-liveticker2.php | 1 + 7 files changed, 97 insertions(+), 64 deletions(-) delete mode 100644 includes/ajax.php diff --git a/includes/ajax.php b/includes/ajax.php deleted file mode 100644 index d4f8106..0000000 --- a/includes/ajax.php +++ /dev/null @@ -1,48 +0,0 @@ - 'wplt_tick', - 'posts_per_page' => '-1', - 'tax_query' => array( - array( 'taxonomy' => 'wplt_ticker', - 'field' => 'slug', - 'terms' => $slug - ) - ) - ); - - $wp_query = new WP_Query($args); - $output = ''; - - while ($wp_query->have_posts()) : $wp_query->the_post(); - $output .= '
  • -

    '.get_the_time('d.m.Y H.i').' - '.get_the_title().'

    -

    '.get_the_content().'

  • '; - endwhile; - - // Echo success response - echo $output; - } - die(); -} -//add_action( 'wp_ajax_wplt_download_upload', 'wplt_download_upload_ajax' ); \ No newline at end of file diff --git a/includes/class-wpliveticker2-admin.php b/includes/class-wpliveticker2-admin.php index fb8fc4b..46047e8 100644 --- a/includes/class-wpliveticker2-admin.php +++ b/includes/class-wpliveticker2-admin.php @@ -55,15 +55,34 @@ class WPLiveticker2_Admin extends WPLiveticker2 { * @return void */ public static function register_settings() { - register_setting( 'wplt2_settings', 'wplt2', array( 'WPLiveticker2_Admin', 'validate_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__ ); + add_settings_section( + 'wplt2_settings_general', + __( 'General', 'wplt2' ), + array( 'WPLiveticker2_Admin', 'settings_general_section' ), + 'wplt2-settings-page' + ); // 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' ); + add_settings_field( + 'enable_ajax', + __( 'Use AJAX', 'wplt2' ), + array( 'WPLiveticker2_Admin', 'settings_enable_ajax_field' ), + 'wplt2-settings-page', + 'wplt2_settings_general' ); + + add_settings_field( + 'enable_css', + __( 'Default CSS Styles', 'wplt2' ), + array( 'WPLiveticker2_Admin', 'settings_enable_css_field' ), + 'wplt2-settings-page', + 'wplt2_settings_general' ); } /** @@ -90,11 +109,26 @@ class WPLiveticker2_Admin extends WPLiveticker2 { public static function settings_enable_css_field() { $checked = self::$_options['enable_css']; - echo '