| 1 |
<?php |
| 2 |
/** |
| 3 |
* Flash Toolkit Admin. |
| 4 |
* |
| 5 |
* @class FT_Admin |
| 6 |
* @version 1.0.0 |
| 7 |
* @package FlashToolkit/Admin |
| 8 |
* @category Admin |
| 9 |
* @author ThemeGrill |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* FT_Admin Class |
| 18 |
*/ |
| 19 |
class FT_Admin { |
| 20 |
|
| 21 |
/** |
| 22 |
* Hook in tabs. |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
add_action( 'init', array( $this, 'includes' ) ); |
| 26 |
add_action( 'current_screen', array( $this, 'conditional_includes' ) ); |
| 27 |
add_action( 'admin_footer', 'flash_toolkit_print_js', 25 ); |
| 28 |
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Includes any classes we need within admin. |
| 33 |
*/ |
| 34 |
public function includes() { |
| 35 |
include_once( dirname( __FILE__ ) . '/functions-flash-admin.php' ); |
| 36 |
include_once( dirname( __FILE__ ) . '/functions-flash-meta-box.php' ); |
| 37 |
include_once( dirname( __FILE__ ) . '/class-flash-admin-notices.php' ); |
| 38 |
include_once( dirname( __FILE__ ) . '/class-flash-admin-assets.php' ); |
| 39 |
include_once( dirname( __FILE__ ) . '/class-flash-admin-post-types.php' ); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Include admin files conditionally. |
| 44 |
*/ |
| 45 |
public function conditional_includes() { |
| 46 |
if ( ! $screen = get_current_screen() ) { |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
switch ( $screen->id ) { |
| 51 |
case 'options-permalink' : |
| 52 |
include( 'class-flash-admin-permalink-settings.php' ); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Change the admin footer text on Flash Toolkit admin pages. |
| 58 |
* @param string $footer_text |
| 59 |
* @return string |
| 60 |
*/ |
| 61 |
public function admin_footer_text( $footer_text ) { |
| 62 |
if ( ! current_user_can( 'manage_options' ) || ! function_exists( 'flash_toolkit_get_screen_ids' ) ) { |
| 63 |
return $footer_text; |
| 64 |
} |
| 65 |
$current_screen = get_current_screen(); |
| 66 |
$ft_pages = flash_toolkit_get_screen_ids(); |
| 67 |
|
| 68 |
// Check to make sure we're on a Flash Toolkit admin page. |
| 69 |
if ( isset( $current_screen->id ) && apply_filters( 'flash_toolkit_display_admin_footer_text', in_array( $current_screen->id, $ft_pages ) ) ) { |
| 70 |
// Change the footer text. |
| 71 |
if ( ! get_option( 'flash_toolkit_admin_footer_text_rated' ) ) { |
| 72 |
$footer_text = sprintf( __( 'If you like <strong>Flash Toolkit</strong> please leave us a %s★★★★★%s rating. A huge thanks in advance!', 'flash-toolkit' ), '<a href="https://wordpress.org/support/view/plugin-reviews/flash-toolkit?filter=5#postform" target="_blank" class="flash-toolkit-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'flash-toolkit' ) . '">', '</a>' ); |
| 73 |
flash_toolkit_enqueue_js( " |
| 74 |
jQuery( 'a.flash-toolkit-rating-link' ).click( function() { |
| 75 |
jQuery.post( '" . FT()->ajax_url() . "', { action: 'flash_toolkit_rated' } ); |
| 76 |
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
| 77 |
}); |
| 78 |
" ); |
| 79 |
} else { |
| 80 |
$footer_text = __( 'Thank you for creating with Flash Toolkit.', 'flash-toolkit' ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
return $footer_text; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
new FT_Admin(); |
| 89 |
|