/**
  * Change the admin footer text on RestaurantPress admin pages.
  * @param  string $footer_text
  * @return string
  */
 public function admin_footer_text($footer_text)
 {
     if (!current_user_can('manage_restaurantpress')) {
         return;
     }
     $current_screen = get_current_screen();
     $rp_pages = rp_get_screen_ids();
     // Check to make sure we're on a RestaurantPress admin page
     if (isset($current_screen->id) && apply_filters('restaurantpress_display_admin_footer_text', in_array($current_screen->id, $rp_pages))) {
         // Change the footer text
         if (!get_option('restaurantpress_admin_footer_text_rated')) {
             $footer_text = sprintf(__('If you like <strong>RestaurantPress</strong> please leave us a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s rating. A huge thanks in advance!', 'restaurantpress'), '<a href="https://wordpress.org/support/view/plugin-reviews/restaurantpress?filter=5#postform" target="_blank" class="rp-rating-link" data-rated="' . esc_attr__('Thanks :)', 'restaurantpress') . '">', '</a>');
             rp_enqueue_js("\n\t\t\t\t\tjQuery( 'a.rp-rating-link' ).click( function() {\n\t\t\t\t\t\tjQuery.post( '" . RP()->ajax_url() . "', { action: 'restaurantpress_rated' } );\n\t\t\t\t\t\tjQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );\n\t\t\t\t\t});\n\t\t\t\t");
         } else {
             $footer_text = __('Thank you for creating with RestaurantPress.', 'restaurantpress');
         }
     }
     return $footer_text;
 }
 /**
  * TinyMCE locales function.
  * @param  array $locales TinyMCE locales.
  * @return array
  */
 public function add_tinymce_locales($locales)
 {
     if ($this->is_shortcode_enabled()) {
         $locales['restaurantpress_shortcodes'] = RP()->plugin_path() . '/includes/admin/rp-shortcodes-editor-i18n.php';
     }
     return $locales;
 }
 /**
  * Add notices + styles if needed.
  */
 public function add_notices()
 {
     $notices = get_option('restaurantpress_admin_notices', array());
     if ($notices) {
         wp_enqueue_style('restaurantpress-activation', RP()->plugin_url() . '/assets/css/activation.css', array(), RP_VERSION);
         foreach ($notices as $notice) {
             if (!empty($this->core_notices[$notice]) && apply_filters('restaurantpress_show_admin_notice', true, $notice)) {
                 add_action('admin_notices', array($this, $this->core_notices[$notice]));
             } else {
                 add_action('admin_notices', array($this, 'output_custom_notices'));
             }
         }
     }
 }
 /**
  * Register/enqueue frontend scripts.
  */
 public static function load_scripts()
 {
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = 'yes' === get_option('restaurantpress_enable_lightbox');
     $assets_path = str_replace(array('http:', 'https:'), '', RP()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     if (apply_filters('restaurantpress_is_widget_menu_active', is_active_widget(false, false, 'restaurantpress_widget_menu', true)) || rp_post_content_has_shortcode('restaurantpress_menu')) {
         // Register frontend scripts conditionally
         if ($lightbox_en) {
             self::enqueue_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.6', true);
             self::enqueue_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery', 'prettyPhoto'));
             self::enqueue_style('restaurantpress_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
         }
         // Global frontend scripts
         self::enqueue_script('restaurantpress', $frontend_script_path . 'restaurantpress' . $suffix . '.js', array('jquery'));
         // CSS Styles
         if ($enqueue_styles = self::get_styles()) {
             foreach ($enqueue_styles as $handle => $args) {
                 self::enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
             }
         }
         // Inline Styles
         self::create_primary_styles();
     }
 }
 /**
  * Update DB version to current.
  */
 private static function update_db_version($version = null)
 {
     delete_option('restaurantpress_db_version');
     add_option('restaurantpress_db_version', is_null($version) ? RP()->version : $version);
 }
 /**
  * Settings page.
  *
  * Handles the display of the main RestaurantPress settings page in admin.
  */
 public static function output()
 {
     global $current_section, $current_tab;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     do_action('restaurantpress_settings_start');
     wp_enqueue_script('restaurantpress-settings', RP()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'select2'), RP_VERSION, true);
     wp_localize_script('restaurantpress-settings', 'restaurantpress_settings_params', array('i18n_nav_warning' => __('The changes you made will be lost if you navigate away from this page.', 'restaurantpress')));
     // Include settings pages
     self::get_settings_pages();
     // Get current tab/section
     $current_tab = empty($_GET['tab']) ? 'general' : sanitize_title($_GET['tab']);
     $current_section = empty($_REQUEST['section']) ? '' : sanitize_title($_REQUEST['section']);
     // Save settings if data has been posted
     if (!empty($_POST)) {
         self::save();
     }
     // Add any posted messages
     if (!empty($_GET['rp_error'])) {
         self::add_error(stripslashes($_GET['rp_error']));
     }
     if (!empty($_GET['rp_message'])) {
         self::add_message(stripslashes($_GET['rp_message']));
     }
     // Get tabs for the settings page
     $tabs = apply_filters('restaurantpress_settings_tabs_array', array());
     include 'views/html-admin-settings.php';
 }
         * @return string
         */
        public function plugin_path()
        {
            return untrailingslashit(plugin_dir_path(__FILE__));
        }
        /**
         * Get Ajax URL.
         * @return string
         */
        public function ajax_url()
        {
            return admin_url('admin-ajax.php', 'relative');
        }
    }
}
/**
 * Main instance of RestaurantPress.
 *
 * Returns the main instance of RP to prevent the need to use globals.
 *
 * @since  1.0.0
 * @return RestaurantPress
 */
function RP()
{
    return RestaurantPress::get_instance();
}
// Global for backwards compatibility.
$GLOBALS['restaurantpress'] = RP();
/**
 * Get the placeholder image URL.
 * @return string
 */
function rp_placeholder_img_src($thumb_size = 'small')
{
    return apply_filters('restaurantpress_placeholder_img_src', RP()->plugin_url() . '/assets/images/placeholder-' . $thumb_size . '.jpg');
}
 /**
  * Enqueue scripts.
  */
 public function admin_scripts()
 {
     $screen = get_current_screen();
     $screen_id = $screen ? $screen->id : '';
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     // Register Scripts
     wp_register_script('restaurantpress-admin', RP()->plugin_url() . '/assets/js/admin/admin' . $suffix . '.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip'), RP_VERSION);
     wp_register_script('rp-admin-meta-boxes', RP()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'jquery-tiptip', 'rp-enhanced-select'), RP_VERSION);
     wp_register_script('jquery-tiptip', RP()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array('jquery'), RP_VERSION, true);
     wp_register_script('select2', RP()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.4');
     wp_register_script('rp-enhanced-select', RP()->plugin_url() . '/assets/js/admin/enhanced-select' . $suffix . '.js', array('jquery', 'select2'), RP_VERSION);
     wp_localize_script('rp-enhanced-select', 'rp_enhanced_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'restaurantpress'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'restaurantpress'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'restaurantpress'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'restaurantpress'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'restaurantpress'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'restaurantpress'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'restaurantpress'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'restaurantpress'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'restaurantpress'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'restaurantpress'), 'i18n_load_more' => _x('Loading more results&hellip;', 'enhanced select', 'restaurantpress'), 'i18n_searching' => _x('Searching&hellip;', 'enhanced select', 'restaurantpress')));
     // RestaurantPress admin pages
     if (in_array($screen_id, rp_get_screen_ids())) {
         wp_enqueue_script('iris');
         wp_enqueue_script('restaurantpress-admin');
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_script('jquery-ui-autocomplete');
         $params = array('ajax_url' => admin_url('admin-ajax.php'));
         wp_localize_script('restaurantpress-admin', 'restaurantpress_admin', $params);
     }
     // Edit food menu category pages
     if (in_array($screen_id, array('edit-food_menu_cat'))) {
         wp_enqueue_media();
     }
     // Meta boxes
     if (in_array($screen_id, array('food_group', 'edit-food_group'))) {
         wp_register_script('rp-admin-group-meta-boxes', RP()->plugin_url() . '/assets/js/admin/meta-boxes-group' . $suffix . '.js', array('rp-admin-meta-boxes'), RP_VERSION);
         wp_enqueue_script('rp-admin-group-meta-boxes');
     }
     // Widgets Specific
     if (in_array($screen_id, array('widgets', 'customize'))) {
         wp_register_script('rp-admin-widgets', RP()->plugin_url() . '/assets/js/admin/widgets' . $suffix . '.js', array('jquery', 'wp-color-picker'), RP_VERSION);
         wp_enqueue_script('rp-admin-widgets');
     }
 }