diff --git a/assets/js/admin.js b/assets/js/admin.js index 85ebdd8..9d5976d 100755 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -6,7 +6,7 @@ jQuery(document).ready(function ($) { // Uploading files var file_frame; - jQuery.fn.ssp_upload_media_file = function (button, preview_media) { + jQuery.fn.homes_report_upload_media_file = function (button, preview_media) { var button_id = button.attr('id'); var field_id = button_id.replace('_button', ''); var preview_id = button_id.replace('_button', '_preview'); @@ -41,7 +41,7 @@ jQuery(document).ready(function ($) { jQuery('#upload_media_file_button').click(function (event) { event.preventDefault(); - jQuery.fn.ssp_upload_media_file(jQuery(this), false); + jQuery.fn.homes_report_upload_media_file(jQuery(this), false); }); }); \ No newline at end of file diff --git a/classes/class-homes-report-admin.php b/classes/class-homes-report-admin.php index 5f68ac9..fda0b05 100755 --- a/classes/class-homes-report-admin.php +++ b/classes/class-homes-report-admin.php @@ -1,318 +1,332 @@ dir = dirname( $file ); - $this->file = $file; - $this->assets_dir = trailingslashit( $this->dir ) . 'assets'; - $this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $file ) ) ); - $this->home_url = trailingslashit( home_url() ); - $this->token = 'pf_homes_report'; - - // Register homes report settings - add_action( 'admin_init', [ $this, 'register_settings' ] ); - - // Add settings page to menu - add_action( 'admin_menu', [ $this, 'add_menu_item' ] ); - - // Add settings link to plugins page - add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), [ $this, 'add_settings_link' ] ); - - // Load scripts for settings page - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ], 10 ); - - // Display notices in the WP admin - add_action( 'admin_notices', [ $this, 'admin_notices' ], 10 ); - } - - /** - * Add the menu links for the plugin - * - */ - public function add_menu_item() - { - add_submenu_page( 'edit.php?post_type=' . $this->token, 'Leads', 'Leads', 'manage_options', $this->token . '_leads', [ - $this, - 'leads_page' - ] ); - - add_submenu_page( 'edit.php?post_type=' . $this->token, 'Homes Report Settings', 'Settings', 'manage_options', $this->token . '_settings', [ - $this, - 'settings_page' - ] ); - } - - /** - * Add the link to our Settings page - * from the plugins page - * - * @param array $links - * - * @return array - */ - public function add_settings_link( $links ) - { - $settings_link = 'Settings'; - array_push( $links, $settings_link ); - - return $links; - } - - /** - * Register the Javascript files used by - * the plugin in the WordPress dashboard - * - */ - public function enqueue_admin_scripts() - { - global $wp_version; - // Admin JS - wp_register_script( $this->token . '-admin', esc_url( $this->assets_url . 'js/admin.js' ), [ 'jquery' ] ); - wp_enqueue_script( $this->token . '-admin' ); - - if ( $wp_version >= 3.5 ) - wp_enqueue_media(); - } - - /** - * Define different notices that can be - * displayed to the user in the dashboard - * - */ - public function admin_notices() - { - global $wp_version; - - // Version notice - if ( $wp_version < 3.5 ) { - ?> -
token ), '', '', $wp_version ); ?>
-' . __( 'These are a few simple settings for setting up your homes report pages.', $this->token ) . '
'; - } - - /** - * Create the slug field for the Settings page. - * The slug field allows users to choose which - * subdirectory their homes report pages are nested in. - * - */ - public function slug_field() - { - $option = get_option( $this->token . '_slug' ); - - $data = 'homes-report'; - if ( $option && strlen( $option ) > 0 && $option != '' ) - $data = $option; - - echo ' - '; - } - - /** - * Validates that a slug has been defined, - * and formats it properly as a URL - * - * @param string $slug - * - * @return string - */ - public function validate_slug( $slug ) - { - if ( $slug && strlen( $slug ) > 0 && $slug != '' ) - $slug = urlencode( strtolower( str_replace( ' ', '-', $slug ) ) ); - - return $slug; - } - - /** - * Create the FrontDesk key field for the Settings page. - * The FrontDesk key field allows users to define their - * API key to be used in all FrontDesk requests. - */ - public function frontdesk_key_field() - { - $option = get_option( $this->token . '_frontdesk_key' ); - - $data = get_option( 'pf_frontdesk_key', '' ); - if ( $option && strlen( $option ) > 0 && $option != '' ) - $data = $option; - - echo ' - '; - - } - - /** - * Create the actual HTML structure - * for the Settings page for the plugin - * - */ - public function settings_page() - { - if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] == true ) { - flush_rewrite_rules(); - echo 'Successfully updated.
token), '', '', $wp_version); ?>
+' . __('These are a few simple settings for setting up your homes report pages.', $this->token) . '
'; + } + + /** + * Create the slug field for the Settings page. + * The slug field allows users to choose which + * subdirectory their homes report pages are nested in. + * + */ + public function slug_field() + { + $option = get_option($this->token . '_slug'); + + $data = 'homes-report'; + if ($option && strlen($option) > 0 && $option != '') + $data = $option; + + echo ' + '; + } + + /** + * Validates that a slug has been defined, + * and formats it properly as a URL + * + * @param string $slug + * + * @return string + */ + public function validate_slug($slug) + { + if ($slug && strlen($slug) > 0 && $slug != '') + $slug = urlencode(strtolower(str_replace(' ', '-', $slug))); + + return $slug; + } + + /** + * Create the FrontDesk key field for the Settings page. + * The FrontDesk key field allows users to define their + * API key to be used in all FrontDesk requests. + */ + public function frontdesk_key_field() + { + $option = get_option($this->token . '_frontdesk_key'); + + $data = get_option('pf_frontdesk_key', ''); + if ($option && strlen($option) > 0 && $option != '') + $data = $option; + + echo ' + '; + + } + + /** + * Create the actual HTML structure + * for the Settings page for the plugin + * + */ + public function settings_page() + { + if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true) { + flush_rewrite_rules(); + echo 'Successfully updated.
The requested leads have been deleted!