includes();
/**
* Load admin assets.
*/
add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) );
/**
* Add filters for WordPress header and footer text.
*/
add_filter( 'update_footer', array( $this, 'filter_update_footer' ), 50 );
add_filter( 'admin_footer_text', array( $this, 'filter_admin_footer_text' ), 50 );
/**
* Admin page header.
*/
add_action( 'in_admin_header', array( $this, 'admin_header' ), 100 );
/**
* Admin page footer.
*/
add_action( 'in_admin_footer', array( $this, 'admin_footer' ), 100 );
/**
* Add notices.
*/
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
/**
* After admin loaded
*/
do_action( 'bloghash_admin_loaded' );
}
/**
* Includes files.
*
* @since 1.0.0
*/
private function includes() {
/**
* Include helper functions.
*/
require_once BLOGHASH_THEME_PATH . '/inc/admin/helpers.php'; // phpcs:ignore
/**
* Include Bloghash welcome page.
*/
require_once BLOGHASH_THEME_PATH . '/inc/admin/class-bloghash-dashboard.php'; // phpcs:ignore
/**
* Guten block
*/
// require_once BLOGHASH_THEME_PATH . '/inc/admin/guten-block.php'; // phpcs:ignore
/**
* Include Bloghash meta boxes.
*/
require_once BLOGHASH_THEME_PATH . '/inc/admin/metabox/class-bloghash-meta-boxes.php'; // phpcs:ignore
}
/**
* Load our required assets on admin pages.
*
* @since 1.0.0
* @param string $hook it holds the information about the current page.
*/
public function load_assets( $hook ) {
/**
* Do not enqueue if we are not on one of our pages.
*/
if ( ! bloghash_is_admin_page( $hook ) ) {
return;
}
// Script debug.
$prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'dev/' : '';
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
/**
* Enqueue admin pages stylesheet.
*/
wp_enqueue_style(
'bloghash-admin-styles',
BLOGHASH_THEME_URI . '/inc/admin/assets/css/bloghash-admin' . $suffix . '.css',
false,
BLOGHASH_THEME_VERSION
);
/**
* Enqueue admin pages script.
*/
wp_enqueue_script(
'bloghash-admin-script',
BLOGHASH_THEME_URI . '/inc/admin/assets/js/' . $prefix . 'bloghash-admin' . $suffix . '.js',
array( 'jquery', 'wp-util', 'updates' ),
BLOGHASH_THEME_VERSION,
true
);
/**
* Localize admin strings.
*/
$texts = array(
'install' => esc_html__( 'Install', 'bloghash' ),
'install-inprogress' => esc_html__( 'Installing...', 'bloghash' ),
'activate-inprogress' => esc_html__( 'Activating...', 'bloghash' ),
'deactivate-inprogress' => esc_html__( 'Deactivating...', 'bloghash' ),
'active' => esc_html__( 'Active', 'bloghash' ),
'retry' => esc_html__( 'Retry', 'bloghash' ),
'please_wait' => esc_html__( 'Please Wait...', 'bloghash' ),
'importing' => esc_html__( 'Importing... Please Wait...', 'bloghash' ),
'currently_processing' => esc_html__( 'Currently processing: ', 'bloghash' ),
'import' => esc_html__( 'Import', 'bloghash' ),
'import_demo' => esc_html__( 'Import Demo', 'bloghash' ),
'importing_notice' => esc_html__( 'The demo importer is still working. Closing this window may result in failed import.', 'bloghash' ),
'import_complete' => esc_html__( 'Import Complete!', 'bloghash' ),
'import_complete_desc' => esc_html__( 'The demo has been imported.', 'bloghash' ) . ' ' . esc_html__( 'Visit site.', 'bloghash' ) . '',
);
$strings = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'wpnonce' => wp_create_nonce( 'bloghash_nonce' ),
'texts' => $texts,
'color_pallete' => array( '#F43676', '#06cca6', '#2c2e3a', '#e4e7ec', '#f0b849', '#ffffff', '#000000' ),
);
$strings = apply_filters( 'bloghash_admin_strings', $strings );
wp_localize_script( 'bloghash-admin-script', 'hester_strings', $strings );
}
/**
* Filters WordPress footer right text to hide all text.
*
* @since 1.0.0
* @param string $text Text that we're going to replace.
*/
public function filter_update_footer( $text ) {
$base = get_current_screen()->base;
/**
* Only do this if we are on one of our plugin pages.
*/
if ( bloghash_is_admin_page( $base ) ) {
return apply_filters( 'bloghash_footer_version', esc_html__( 'BlogHash Theme', 'bloghash' ) . ' ' . BLOGHASH_THEME_VERSION . '
' );
} else {
return $text;
}
}
/**
* Filter WordPress footer left text to display our text.
*
* @since 1.0.0
* @param string $text Text that we're going to replace.
*/
public function filter_admin_footer_text( $text ) {
if ( bloghash_is_admin_page() ) {
return;
}
return $text;
}
/**
* Outputs the page admin header.
*
* @since 1.0.0
*/
public function admin_header() {
$base = get_current_screen()->base;
if ( ! bloghash_is_admin_page( $base ) ) {
return;
}
?>