class-do-css.php
6 years ago
class-enqueue-css.php
6 years ago
class-settings.php
6 years ago
dashboard.php
6 years ago
defaults.php
6 years ago
functions.php
6 years ago
general.php
6 years ago
generate-css.php
6 years ago
dashboard.php
229 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Our admin Dashboard. |
| 4 | * |
| 5 | * @package GenerateBlocks |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | add_action( 'admin_menu', 'generateblocks_register_dashboard' ); |
| 13 | /** |
| 14 | * Register our Dashboard page. |
| 15 | * |
| 16 | * @since 0.1 |
| 17 | */ |
| 18 | function generateblocks_register_dashboard() { |
| 19 | add_options_page( |
| 20 | __( 'GenerateBlocks', 'generateblocks' ), |
| 21 | __( 'GenerateBlocks', 'generateblocks' ), |
| 22 | 'manage_options', |
| 23 | 'generateblocks', |
| 24 | 'generateblocks_do_dashboard' |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | add_action( 'admin_head', 'generateblocks_fix_dashboard_menu_item' ); |
| 29 | /** |
| 30 | * Highlight the Settings menu item when on the Dashboard. |
| 31 | * |
| 32 | * @since 1.0 |
| 33 | */ |
| 34 | function generateblocks_fix_dashboard_menu_item() { |
| 35 | global $parent_file, $submenu_file; |
| 36 | $screen = get_current_screen(); |
| 37 | |
| 38 | if ( 'settings_page_generateblocks' === $screen->id ) { |
| 39 | $submenu_file = 'generateblocks-settings'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 40 | } |
| 41 | |
| 42 | remove_submenu_page( 'options-general.php', 'generateblocks' ); |
| 43 | } |
| 44 | |
| 45 | add_action( 'admin_enqueue_scripts', 'generateblocks_enqueue_dashboard_scripts' ); |
| 46 | /** |
| 47 | * Add our scripts to the page. |
| 48 | * |
| 49 | * @since 0.1 |
| 50 | */ |
| 51 | function generateblocks_enqueue_dashboard_scripts() { |
| 52 | $screen = get_current_screen(); |
| 53 | |
| 54 | if ( 'settings_page_generateblocks' === $screen->id || 'settings_page_generateblocks-settings' === $screen->id ) { |
| 55 | wp_enqueue_style( |
| 56 | 'generateblocks-dashboard', |
| 57 | GENERATEBLOCKS_DIR_URL . 'assets/css/dashboard.css', |
| 58 | array(), |
| 59 | filemtime( GENERATEBLOCKS_DIR . 'assets/css/dashboard.css' ) |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Build our Dashboard menu. |
| 66 | */ |
| 67 | function generateblocks_dashboard_navigation() { |
| 68 | $screen = get_current_screen(); |
| 69 | |
| 70 | $tabs = apply_filters( |
| 71 | 'generateblocks_dashboard_tabs', |
| 72 | array( |
| 73 | 'dashboard' => array( |
| 74 | 'name' => __( 'Dashboard', 'generateblocks' ), |
| 75 | 'url' => admin_url( 'options-general.php?page=generateblocks' ), |
| 76 | 'class' => 'settings_page_generateblocks' === $screen->id ? 'active' : '', |
| 77 | ), |
| 78 | 'settings' => array( |
| 79 | 'name' => __( 'Settings', 'generateblocks' ), |
| 80 | 'url' => admin_url( 'options-general.php?page=generateblocks-settings' ), |
| 81 | 'class' => 'settings_page_generateblocks-settings' === $screen->id ? 'active' : '', |
| 82 | ), |
| 83 | ) |
| 84 | ); |
| 85 | |
| 86 | // Don't print any markup if we only have one tab. |
| 87 | if ( count( $tabs ) === 1 ) { |
| 88 | return; |
| 89 | } |
| 90 | ?> |
| 91 | <div class="gblocks-navigation"> |
| 92 | <?php |
| 93 | foreach ( $tabs as $tab ) { |
| 94 | printf( |
| 95 | '<a href="%1$s" class="%2$s">%3$s</a>', |
| 96 | esc_url( $tab['url'] ), |
| 97 | esc_attr( $tab['class'] ), |
| 98 | esc_html( $tab['name'] ) |
| 99 | ); |
| 100 | } |
| 101 | ?> |
| 102 | </div> |
| 103 | <?php |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Output our Dashboard HTML. |
| 108 | * |
| 109 | * @since 0.1 |
| 110 | */ |
| 111 | function generateblocks_do_dashboard() { |
| 112 | ?> |
| 113 | <div class="wrap gblocks-dashboard-wrap"> |
| 114 | <div class="gblocks-dashboard-header"> |
| 115 | <div class="gblocks-logo"> |
| 116 | <a href="https://generateblocks.com" target="_blank" rel="noopener noreferrer"> |
| 117 | <img width="200" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/gb-logo-black.svg'; ?>" alt="" /> |
| 118 | </a> |
| 119 | <span class="gblocks-version"><?php echo esc_html( GENERATEBLOCKS_VERSION ); ?></span> |
| 120 | </div> |
| 121 | |
| 122 | <?php generateblocks_dashboard_navigation(); ?> |
| 123 | </div> |
| 124 | |
| 125 | <div class="gblocks-dashboard-intro-content"> |
| 126 | <?php esc_html_e( 'A small collection of lightweight WordPress blocks that can accomplish nearly anything.', 'generateblocks' ); ?> |
| 127 | |
| 128 | <div class="gblocks-sub-navigation"> |
| 129 | <a class="button" href="https://generateblocks.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn More', 'generateblocks' ); ?></a> |
| 130 | <a class="button" href="https://docs.generateblocks.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Documentation', 'generateblocks' ); ?></a> |
| 131 | </div> |
| 132 | </div> |
| 133 | |
| 134 | <div class="gblocks-dashboard-content-container"> |
| 135 | <div class="gblocks-dashboard-blocks"> |
| 136 | <div class="gblocks-block"> |
| 137 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 20 20" xml:space="preserve"> |
| 138 | <path style="fill:currentColor;" class="st0" d="M2.8 3.4c0-.4.3-.7.7-.7h1.2V0H3.4C1.5 0 0 1.5 0 3.4v1.2h2.8V3.4zM0 7.4h2.8v5.3H0zm17.2 0H20v5.3h-2.8zm0 9.2c0 .4-.3.7-.7.7h-1.2V20h1.2c1.9 0 3.4-1.5 3.4-3.4v-1.2h-2.8v1.2h.1zM7.4 0h5.3v2.8H7.4zm-4 17.2c-.4 0-.7-.3-.7-.7v-1.2H0v1.2c0 2 1.5 3.5 3.4 3.5h1.2v-2.8H3.4zm4 0h5.3V20H7.4zm9.2-14.4c.4 0 .7.3.7.7v1.2H20V3.4C20 1.5 18.5 0 16.6 0h-1.2v2.8h1.2z"/> |
| 139 | </svg> |
| 140 | |
| 141 | <h3><?php esc_html_e( 'Container', 'generateblocks' ); ?></h3> |
| 142 | <p><?php esc_html_e( 'Organize your content into rows and sections.', 'generateblocks' ); ?></p> |
| 143 | </div> |
| 144 | |
| 145 | <div class="gblocks-block"> |
| 146 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 20 20" xml:space="preserve"> |
| 147 | <path style="fill:currentColor;" class="st0" d="M20 .6c0-.3-.2-.6-.5-.6H.5C.2 0 0 .3 0 .6v4.6c0 .3.2.6.5.6h19c.3 0 .5-.3.5-.6V.6zM6.7 7.7c0-.3-.2-.6-.5-.6H.5c-.3 0-.5.3-.5.6v4.6c0 .3.2.6.5.6h5.6c.3 0 .5-.3.5-.6l.1-4.6zm13.2 0c0-.3-.2-.6-.6-.6H8.6c-.4 0-.6.3-.6.6v4.5c0 .3.2.6.6.6h10.8c.3 0 .6-.3.6-.6l-.1-4.5zM20 14.8c0-.3-.2-.6-.5-.6h-5.6c-.3 0-.5.2-.5.6v4.6c0 .3.2.6.5.6h5.6c.3 0 .5-.2.5-.6v-4.6zm-8 0c0-.3-.2-.5-.5-.5H.5c-.3 0-.5.2-.5.5v4.6c0 .4.2.6.5.6h11c.3 0 .5-.2.5-.5v-4.7z"/> |
| 148 | </svg> |
| 149 | |
| 150 | <h3><?php esc_html_e( 'Grid', 'generateblocks' ); ?></h3> |
| 151 | <p><?php esc_html_e( 'Create advanced layouts with flexible grids.', 'generateblocks' ); ?></p> |
| 152 | </div> |
| 153 | |
| 154 | <div class="gblocks-block"> |
| 155 | <svg style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;" xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 38 38" height="100%" width="100%"> |
| 156 | <path style="fill:currentColor;fill-rule:nonzero;" d="M34.82,37.5l-10.183,0l0,-14.037l-11.774,0l0,14.037l-10.183,0l0,-37.5l10.183,0l0,12.652l11.774,0l0,-12.652l10.183,0l0,37.5Z"></path> |
| 157 | </svg> |
| 158 | |
| 159 | <h3><?php esc_html_e( 'Headline', 'generateblocks' ); ?></h3> |
| 160 | <p><?php esc_html_e( 'Craft text-rich content with advanced typography.', 'generateblocks' ); ?></p> |
| 161 | </div> |
| 162 | |
| 163 | <div class="gblocks-block"> |
| 164 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 20 20" xml:space="preserve"> |
| 165 | <path style="fill:currentColor;" class="st0" d="M19.2 0H.8C.4 0 0 .4 0 .8v6.4c0 .4.4.8.8.8h18.4c.4 0 .8-.4.8-.8V.8c0-.4-.4-.8-.8-.8zm-.8 12H1.6c-.9 0-1.6.7-1.6 1.6v4.8c0 .9.7 1.6 1.6 1.6h16.8c.9 0 1.6-.7 1.6-1.6v-4.8c0-.9-.7-1.6-1.6-1.6zm.4 6.4c0 .2-.2.4-.4.4H1.6c-.2 0-.4-.2-.4-.4v-4.8c0-.2.2-.4.4-.4h16.8c.2 0 .4.2.4.4v4.8z"/> |
| 166 | </svg> |
| 167 | |
| 168 | <h3><?php esc_html_e( 'Buttons', 'generateblocks' ); ?></h3> |
| 169 | <p><?php esc_html_e( 'Drive conversions with beautiful buttons.', 'generateblocks' ); ?></p> |
| 170 | </div> |
| 171 | </div> |
| 172 | |
| 173 | <div class="gblocks-getting-started"> |
| 174 | <p><?php esc_html_e( 'To get started, head over to the block editor and open the GenerateBlocks category.', 'generatepress' ); ?></p> |
| 175 | <img width="400" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/add-blocks.png'; ?>" alt="" /> |
| 176 | </div> |
| 177 | |
| 178 | <div class="gblocks-generatepress"> |
| 179 | <div class="gblocks-inside-generatepress"> |
| 180 | <div class="gblocks-generatepress-content"> |
| 181 | <img width="300" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress.svg'; ?>" alt="" /> |
| 182 | <p><?php esc_html_e( 'Looking for a WordPress theme? GenerateBlocks and GeneratePress are built with the same principles in mind and complement each other perfectly.', 'generateblocks' ); ?></p> |
| 183 | <div class="stats"> |
| 184 | <div class="downloads"> |
| 185 | <strong>2,000,000+</strong><br> <?php esc_html_e( 'Downloads', 'generateblocks' ); ?> |
| 186 | </div> |
| 187 | |
| 188 | <div class="stars"> |
| 189 | <strong>900+</strong><br> |
| 190 | <img src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/stars.svg'; ?>" alt="" width="98" height="17" class="alignnone size-full wp-image-44"> |
| 191 | </div> |
| 192 | |
| 193 | <div class="active-websites"> |
| 194 | <strong>200,000+</strong><br> <?php esc_html_e( 'Active websites', 'generateblocks' ); ?> |
| 195 | </div> |
| 196 | |
| 197 | <div class="active-websites"> |
| 198 | <strong>50,000+</strong><br> <?php esc_html_e( 'Happy customers', 'generateblocks' ); ?> |
| 199 | </div> |
| 200 | </div> |
| 201 | <a class="gblocks-button" href="https://generatepress.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'generateblocks' ); ?></a> |
| 202 | </div> |
| 203 | |
| 204 | <div class="gblocks-generatepress-image"> |
| 205 | <img width="450" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress-sites.png'; ?>" alt="" /> |
| 206 | </div> |
| 207 | </div> |
| 208 | </div> |
| 209 | </div> |
| 210 | </div> |
| 211 | <?php |
| 212 | } |
| 213 | |
| 214 | add_action( 'admin_init', 'generateblocks_dashboard_redirect' ); |
| 215 | /** |
| 216 | * Redirect to the Dashboard page on single plugin activation. |
| 217 | * |
| 218 | * @since 0.1 |
| 219 | */ |
| 220 | function generateblocks_dashboard_redirect() { |
| 221 | $do_redirect = apply_filters( 'generateblocks_do_activation_redirect', get_option( 'generateblocks_do_activation_redirect', false ) ); |
| 222 | |
| 223 | if ( $do_redirect ) { |
| 224 | delete_option( 'generateblocks_do_activation_redirect' ); |
| 225 | wp_safe_redirect( esc_url( admin_url( 'options-general.php?page=generateblocks' ) ) ); |
| 226 | exit; |
| 227 | } |
| 228 | } |
| 229 |