/** * 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★★★★★%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; }
/** * 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…', 'enhanced select', 'restaurantpress'), 'i18n_searching' => _x('Searching…', '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'); } }