Giftlight): make the gift guide page in one click, choose guide * or quiz, and see the guide as shoppers will. * * @package Giftlight */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * The admin page's URL. * * @return string */ function giftlight_admin_url() { return admin_url( 'admin.php?page=giftlight' ); } /** * The gift guide page this plugin made, if it still exists and isn't in the trash. * * @return WP_Post|null */ function giftlight_page() { $id = (int) get_option( 'giftlight_page_id', 0 ); $p = $id ? get_post( $id ) : null; return ( $p && 'page' === $p->post_type && 'trash' !== $p->post_status ) ? $p : null; } add_action( 'admin_menu', function () { add_submenu_page( 'woocommerce', __( 'Giftlight', 'giftlight' ), __( 'Giftlight', 'giftlight' ), 'manage_woocommerce', 'giftlight', 'giftlight_admin_page' ); }, 60 ); add_filter( 'plugin_action_links_' . plugin_basename( GIFTLIGHT_FILE ), function ( $links ) { array_unshift( $links, '' . esc_html__( 'Set up', 'giftlight' ) . '' ); return $links; } ); /** * Until the gift guide page exists, one line on the Plugins and Dashboard screens points to it. */ add_action( 'admin_notices', function () { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen || ! in_array( $screen->id, array( 'plugins', 'dashboard' ), true ) ) { return; } if ( giftlight_page() || ! current_user_can( 'manage_woocommerce' ) || get_option( 'giftlight_notice_dismissed' ) ) { return; } printf( '
%1$s %3$s
' . esc_html__( 'Saved.', 'giftlight' ) . '
' . esc_html__( 'Giftlight sorts your products into a gift guide: who it’s for, what to spend and what they’re into, read from your own categories, tags and prices. A short gift quiz sits one tap away for shoppers who’d rather be asked. It follows your shop by itself: add a product or change a price and the guide changes with it.', 'giftlight' ) . '
'; echo '' . esc_html( sprintf( __( 'Your Gift Guide page is %s.', 'giftlight' ), $status ) ) . ' '; echo '' . esc_html__( 'Edit the page', 'giftlight' ) . ' '; echo '' . esc_html( 'publish' === $page->post_status ? __( 'View it', 'giftlight' ) : __( 'Preview it', 'giftlight' ) ) . '
'; if ( 'publish' !== $page->post_status ) { echo '' . esc_html__( 'Publish it when you’re happy with it, then add it to your menu (Appearance > Menus, or the Navigation block).', 'giftlight' ) . '
'; } } else { echo ''; } echo '' . esc_html__( 'Or add it anywhere: the “Gift guide” block, or the shortcode', 'giftlight' ) . ' [giftlight] ([giftlight layout="quiz"] ' . esc_html__( 'for the quiz).', 'giftlight' ) . '
' . esc_html( sprintf( _n( 'Built from %1$d product in stock with a photo and a price, across %2$d categories.', 'Built from %1$d products in stock with a photo and a price, across %2$d categories.', $count, 'giftlight' ), $count, count( $catalog['collections'] ) ) ) . ' '; echo esc_html__( 'Category names like “Kitchen” or “For him” and tags become sections; names like “Sale”, “New” or “Uncategorized” are left out.', 'giftlight' ) . '
'; echo '' . esc_html__( 'Nothing leaves your site: the guide is built in the shopper’s browser from your product data, with no tracking and no outside requests.', 'giftlight' ) . '
'; echo '