Changeset 2967544
- Timestamp:
- 09/15/2023 02:37:05 PM (3 years ago)
- Location:
- bestseller-lists-from-new-york-times
- Files:
-
- 26 added
- 9 deleted
- 4 edited
- 5 copied
-
tags/2.3.0 (copied) (copied from bestseller-lists-from-new-york-times/trunk)
-
tags/2.3.0/admin-page.php (copied) (copied from bestseller-lists-from-new-york-times/trunk/admin-page.php) (2 diffs)
-
tags/2.3.0/block-registration.php (deleted)
-
tags/2.3.0/build (added)
-
tags/2.3.0/build/lists (added)
-
tags/2.3.0/build/lists/block.json (added)
-
tags/2.3.0/build/lists/index.asset.php (added)
-
tags/2.3.0/build/lists/index.js (added)
-
tags/2.3.0/build/lists/render.php (added)
-
tags/2.3.0/build/ui (added)
-
tags/2.3.0/build/ui/block.json (added)
-
tags/2.3.0/build/ui/public.asset.php (added)
-
tags/2.3.0/build/ui/public.css (added)
-
tags/2.3.0/build/ui/public.js (added)
-
tags/2.3.0/class-nytbestsellerlistings.php (added)
-
tags/2.3.0/css (deleted)
-
tags/2.3.0/functions.php (copied) (copied from bestseller-lists-from-new-york-times/trunk/functions.php) (2 diffs)
-
tags/2.3.0/index.php (copied) (copied from bestseller-lists-from-new-york-times/trunk/index.php) (2 diffs)
-
tags/2.3.0/js (deleted)
-
tags/2.3.0/nytBestsellerListings.class.php (deleted)
-
tags/2.3.0/plugin-updates.php (added)
-
tags/2.3.0/readme.txt (copied) (copied from bestseller-lists-from-new-york-times/trunk/readme.txt) (2 diffs)
-
tags/2.3.0/shortcodes.php (deleted)
-
trunk/admin-page.php (modified) (2 diffs)
-
trunk/blocks (deleted)
-
trunk/build (added)
-
trunk/build/lists (added)
-
trunk/build/lists/block.json (added)
-
trunk/build/lists/index.asset.php (added)
-
trunk/build/lists/index.js (added)
-
trunk/build/lists/render.php (added)
-
trunk/build/ui (added)
-
trunk/build/ui/block.json (added)
-
trunk/build/ui/public.asset.php (added)
-
trunk/build/ui/public.css (added)
-
trunk/build/ui/public.js (added)
-
trunk/class-nytbestsellerlistings.php (added)
-
trunk/functions.php (modified) (2 diffs)
-
trunk/index.php (modified) (2 diffs)
-
trunk/nytBestsellerListings.class.php (deleted)
-
trunk/plugin-updates.php (added)
-
trunk/plugin_updates.php (deleted)
-
trunk/public-assets (deleted)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bestseller-lists-from-new-york-times/tags/2.3.0/admin-page.php
r2853610 r2967544 1 1 <?php 2 defined( 'ABSPATH') || die('Not allowed');2 defined( 'ABSPATH' ) || die( 'Not allowed' ); 3 3 4 4 5 if ( isset($_POST['nyt-bestseller-listings-settings']) ) :5 if ( isset( $_POST['nyt-bestseller-listings-settings'] ) ) : 6 6 7 if ( ! wp_verify_nonce( $_POST['_nyt-bestseller-listings-settings-nonce'], 'save-nyt-bestseller-settings' ) ) {7 if ( ! wp_verify_nonce( $_POST['_nyt-bestseller-listings-settings-nonce'], 'save-nyt-bestseller-settings' ) ) { 8 8 echo '<div class="error updated"><p>Could not save. Perhaps the form timed out?</p></div>'; 9 9 } else { 10 nytBestsellerListings::setApiKey( $_POST['nyt_bestseller_listings_apiKey']);10 NytBestsellerListings::setApiKey( sanitize_text_field( $_POST['nyt_bestseller_listings_apiKey'] ) ); 11 11 12 nytBestsellerListings::setCatalogLinkFormat($_POST['nyt_bestseller_listings_CatalogLinkFormat']);12 NytBestsellerListings::setCatalogLinkFormat( sanitize_text_field( $_POST['nyt_bestseller_listings_CatalogLinkFormat'] ) ); 13 13 } 14 14 15 15 endif; 16 16 17 $api Key = nytBestsellerListings::getApiKey();18 $catalog LinkFormat = nytBestsellerListings::getCatalogLinkFormat();17 $api_key = NytBestsellerListings::getApiKey(); 18 $catalog_link_format = NytBestsellerListings::getCatalogLinkFormat(); 19 19 ?> 20 20 <style> … … 37 37 <h1>New York Times Bestseller Listings — Settings</h1> 38 38 <form method="post" action=""> 39 <?php wp_nonce_field( 'save-nyt-bestseller-settings', '_nyt-bestseller-listings-settings-nonce' ) ?>39 <?php wp_nonce_field( 'save-nyt-bestseller-settings', '_nyt-bestseller-listings-settings-nonce' ); ?> 40 40 41 41 <label class="block">API Key</label> 42 42 <p class="help">You can get one of these <a href="https://developer.nytimes.com/signup">here.</a></p> 43 <input type="text" class="wide" name="nyt_bestseller_listings_apiKey" value="<? = esc_attr($apiKey)?>">43 <input type="text" class="wide" name="nyt_bestseller_listings_apiKey" value="<?php echo esc_attr( $api_key ); ?>"> 44 44 45 45 46 46 <label class="block">Catalog Links</label> 47 47 <p class="help">You can add links to your library catalog to each book. Enter the catalog url below, using various placeholders to insert book variables. For example, settings this to <b>http://example.com/?serial={isbn}</b> would insert the book's isbn after the <b>serial=</b> in the resulting url. Leave this blank to hide links to a catalog.</p> 48 <input type="text" class="wide" value="<? = esc_attr($catalogLinkFormat)?>" name="nyt_bestseller_listings_CatalogLinkFormat">48 <input type="text" class="wide" value="<?php echo esc_attr( $catalog_link_format ); ?>" name="nyt_bestseller_listings_CatalogLinkFormat"> 49 49 <p class="help">Placeholders: <b>{isbn}</b>, <b>{title}</b>, <b>{author}</b></p> 50 50 51 <p> 52 <input type="submit" class="button-primary" value="Save" name="nyt-bestseller-listings-settings"> 53 </p> 51 <?php submit_button( 'Save', 'primary', 'nyt-bestseller-listings-settings' ); ?> 52 54 53 </form> -
bestseller-lists-from-new-york-times/tags/2.3.0/functions.php
r2705840 r2967544 1 1 <?php 2 defined( 'ABSPATH') || die('Not allowed');2 defined( 'ABSPATH' ) || die( 'Not allowed' ); 3 3 4 4 5 function nytBestsellerListings_mainDisplay ($atts, $content){6 wp_enqueue_script( 'nyt-bestseller-listings');7 wp_enqueue_style( 'nyt-bestseller-listings');5 function NytBestsellerListings_mainDisplay ( $atts, $content ) { 6 wp_enqueue_script( 'nyt-bestseller-listings' ); 7 wp_enqueue_style( 'nyt-bestseller-listings' ); 8 8 9 if ( isset($atts['initialList']) )9 if ( isset( $atts['initialList'] ) ) 10 10 $atts['initial-list'] = $atts['initialList']; 11 11 12 12 $atts = shortcode_atts([ 13 'initial-list' => nytBestsellerListings::getDefaultList(),13 'initial-list' => NytBestsellerListings::getDefaultList(), 14 14 'displayImages' => '1', 15 15 ], $atts, 'nyt_bestseller_listings' ); 16 16 17 if ( isset($_GET['nytlist']) )18 $atts['initial-list'] = $_GET['nytlist'];17 if ( isset( $_GET['nytlist'] ) ) 18 $atts['initial-list'] = sanitize_text_field( $_GET['nytlist'] ); 19 19 20 if ( $atts['displayImages']==='1') {21 $display Images = true;22 $display ImagesJs = "true";20 if ( $atts['displayImages'] === '1' ) { 21 $display_images = true; 22 $display_images_js = 'true'; 23 23 } else { 24 $display Images = false;25 $display ImagesJs = "false";24 $display_images = false; 25 $display_images_js = 'false'; 26 26 } 27 27 28 $js = <<<JS28 $js = ' 29 29 bslnyt = window.bslnyt || {}; 30 bslnyt.displayImages = ' . esc_js( $display_images_js ) . '; 31 '; 30 32 31 bslnyt.displayImages = $displayImagesJs; 32 JS; 33 wp_add_inline_script('nyt-bestseller-listings', $js, 'before' ); 33 wp_add_inline_script( 'nyt-bestseller-listings', $js, 'before' ); 34 34 35 $dropdown = nytBestsellerListings::getListsDropdown( $atts['initial-list'] );35 $dropdown = NytBestsellerListings::getListsDropdown( $atts['initial-list'] ); 36 36 37 if ( $dropdown) :38 $out = $dropdown 37 if ( ! empty( $dropdown ) ) : 38 $out = $dropdown 39 39 . '<div class="nyt-bestseller-listings-booklist">' 40 . nytBestsellerListings::getBookList( $atts['initial-list'], false, $displayImages )41 . '</div>' 40 . NytBestsellerListings::getBookList( $atts['initial-list'], true, $display_images ) 41 . '</div>' 42 42 . $dropdown; 43 43 else : … … 46 46 47 47 return $out; 48 49 48 } -
bestseller-lists-from-new-york-times/tags/2.3.0/index.php
r2955023 r2967544 4 4 Plugin URI: https://jakeparis.com/wordpress-plugins/ 5 5 Description: Integrate bestseller lists from the New York Times into your own site with a user-friendly interface. 6 Version: 2. 2.07 Requires PHP: 5.48 Requires at least: 4.96 Version: 2.3.0 7 Requires PHP: 7.4 8 Requires at least: 5.4 9 9 Tested up to: 6.3.0 10 10 Author: Jake Paris … … 13 13 License URI: https://opensource.org/licenses/GPL-3.0 14 14 */ 15 defined( 'ABSPATH' ) || die( 'Not allowed' ); 15 16 16 define( 'BSLNYT_PLUGIN_VERSION', '2.2.0');17 define( 'BSLNYT_PLUGIN_PATH', plugin_dir_path(__FILE__) );18 define( 'BSLNYT_PLUGIN_URL', plugins_url('/', __FILE__) );17 define( 'BSLNYT_PLUGIN_VERSION', '2.3.0' ); 18 define( 'BSLNYT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 19 define( 'BSLNYT_PLUGIN_URL', plugins_url( '/', __FILE__ ) ); 19 20 20 if( function_exists('register_block_type') )21 require_once BSLNYT_PLUGIN_PATH . 'blocks/block-registration.php';22 21 23 require_once BSLNYT_PLUGIN_PATH . ' nytBestsellerListings.class.php';22 require_once BSLNYT_PLUGIN_PATH . 'class-nytbestsellerlistings.php'; 24 23 require_once BSLNYT_PLUGIN_PATH . 'functions.php'; 25 24 26 require_once BSLNYT_PLUGIN_PATH . 'plugin _updates.php';25 require_once BSLNYT_PLUGIN_PATH . 'plugin-updates.php'; 27 26 28 add_action('wp_enqueue_scripts', function(){29 wp_register_script( 'nyt-bestseller-listings', 30 BSLNYT_PLUGIN_URL . ' public-assets/build/nyt-bestseller-listings.js',27 add_action('wp_enqueue_scripts', function () { 28 wp_register_script( 'nyt-bestseller-listings', 29 BSLNYT_PLUGIN_URL . 'build/ui/public.js', 31 30 array( 32 'jquery' 33 ), 31 'jquery', 32 ), 34 33 BSLNYT_PLUGIN_VERSION 35 34 ); 36 wp_register_style ( 'nyt-bestseller-listings',37 BSLNYT_PLUGIN_URL . ' public-assets/build/nyt-bestseller-listings.css',35 wp_register_style( 'nyt-bestseller-listings', 36 BSLNYT_PLUGIN_URL . 'build/ui/public.css', 38 37 array(), 39 38 BSLNYT_PLUGIN_VERSION 40 39 ); 41 40 42 if( ! empty($_SERVER['HTTPS']) ) 43 $js_args = array('ajaxurl' => admin_url( 'admin-ajax.php','https' ) ); 44 else 45 $js_args = array('ajaxurl' => admin_url( 'admin-ajax.php','http' ) ); 41 if ( ! empty( $_SERVER['HTTPS'] ) ) { 42 $js_args = array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'https' ) ); 43 } else { 44 $js_args = array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'http' ) ); 45 } 46 46 wp_localize_script( 'nyt-bestseller-listings', 'nyt_bestseller_listings_settings', $js_args ); 47 47 }); 48 48 49 49 50 add_action('init',function(){ 51 add_shortcode( 'nyt-bestseller-listings', 'nytBestsellerListings_mainDisplay'); 50 add_action('init', function () { 51 add_shortcode( 'nyt-bestseller-listings', function ( $atts, $content ) { 52 return wp_kses_post( NytBestsellerListings_mainDisplay( $atts, $content ) ); 53 }); 54 55 register_block_type( BSLNYT_PLUGIN_PATH . 'build/lists/block.json' ); 52 56 }); 53 57 54 add_action('admin_menu',function(){ 58 59 add_action('admin_menu', function () { 55 60 add_options_page( 'NYT Bestseller Lists', 'NYT Bestseller Lists', 'activate_plugins', 'nyt-bestseller-lists', 'nytBestSellerListings_adminPage' ); 56 61 }); 57 62 58 function nytBestSellerListings_adminPage() {63 function nytBestSellerListings_adminPage() { 59 64 require_once BSLNYT_PLUGIN_PATH . 'admin-page.php'; 60 65 } 61 66 62 67 63 add_action( 'wp_ajax_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList');64 add_action( 'wp_ajax_nopriv_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList');65 function nytBestSellerListings_ajax_getList() {66 $list = $_REQUEST['listName'];68 add_action( 'wp_ajax_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList' ); 69 add_action( 'wp_ajax_nopriv_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList' ); 70 function nytBestSellerListings_ajax_getList() { 71 $list = sanitize_text_field( $_GET['listName'] ); 67 72 68 $display Images = ( isset($_REQUEST['displayImages']) )69 ? (bool) $_ REQUEST['displayImages']73 $display_images = ( isset( $_GET['displayImages'] ) ) 74 ? (bool) $_GET['displayImages'] 70 75 : true; 71 76 72 $html = nytBestsellerListings::getBookList( $list, false, $displayImages );73 echo $html;77 $html = NytBestsellerListings::getBookList( $list, true, $display_images ); 78 echo wp_kses_post( $html ); 74 79 exit; 75 80 } 76 81 82 add_action( 'wp_ajax_nyt_bestseller_listings_getAllLists', 'nytBestSellerListings_ajax_getAllLists' ); 83 add_action( 'wp_ajax_nopriv_nyt_bestseller_listings_getAllLists', 'nytBestSellerListings_ajax_getAllLists' ); 84 function nytBestSellerListings_ajax_getAllLists () { 85 $all_lists = NytBestsellerListings::getResults( 'names.json' ); 86 $all_lists_configured = []; 87 if ( ! empty( $all_lists ) ) { 88 foreach ( $all_lists->results as $list ) { 89 $all_lists_configured[] = [ 90 'label' => $list->display_name, 91 'value' => $list->list_name_encoded, 92 ]; 93 } 94 } 95 wp_send_json_success( $all_lists_configured ); 96 } 77 97 78 register_deactivation_hook(__FILE__, function (){79 delete_option( 'nyt_bestseller_listings_apiKey');80 delete_option( 'nyt_bestseller_listings_defaultList');98 register_deactivation_hook(__FILE__, function () { 99 delete_option( 'nyt_bestseller_listings_apiKey' ); 100 delete_option( 'nyt_bestseller_listings_defaultList' ); 81 101 }); -
bestseller-lists-from-new-york-times/tags/2.3.0/readme.txt
r2955023 r2967544 3 3 Donate link: https://jakeparis.com/ 4 4 Tags: books, library, bestsellers, libraries, reading lists 5 Requires at least: 4.95 Requires at least: 5.4 6 6 Tested up to: 6.3.0 7 7 Stable tag: 2.2.0 … … 46 46 47 47 == Changelog == 48 49 = 2.3.0 = 50 51 Reorganization of plugin; housekeeping. 48 52 49 53 = 2.2.0 = -
bestseller-lists-from-new-york-times/trunk/admin-page.php
r2853610 r2967544 1 1 <?php 2 defined( 'ABSPATH') || die('Not allowed');2 defined( 'ABSPATH' ) || die( 'Not allowed' ); 3 3 4 4 5 if ( isset($_POST['nyt-bestseller-listings-settings']) ) :5 if ( isset( $_POST['nyt-bestseller-listings-settings'] ) ) : 6 6 7 if ( ! wp_verify_nonce( $_POST['_nyt-bestseller-listings-settings-nonce'], 'save-nyt-bestseller-settings' ) ) {7 if ( ! wp_verify_nonce( $_POST['_nyt-bestseller-listings-settings-nonce'], 'save-nyt-bestseller-settings' ) ) { 8 8 echo '<div class="error updated"><p>Could not save. Perhaps the form timed out?</p></div>'; 9 9 } else { 10 nytBestsellerListings::setApiKey( $_POST['nyt_bestseller_listings_apiKey']);10 NytBestsellerListings::setApiKey( sanitize_text_field( $_POST['nyt_bestseller_listings_apiKey'] ) ); 11 11 12 nytBestsellerListings::setCatalogLinkFormat($_POST['nyt_bestseller_listings_CatalogLinkFormat']);12 NytBestsellerListings::setCatalogLinkFormat( sanitize_text_field( $_POST['nyt_bestseller_listings_CatalogLinkFormat'] ) ); 13 13 } 14 14 15 15 endif; 16 16 17 $api Key = nytBestsellerListings::getApiKey();18 $catalog LinkFormat = nytBestsellerListings::getCatalogLinkFormat();17 $api_key = NytBestsellerListings::getApiKey(); 18 $catalog_link_format = NytBestsellerListings::getCatalogLinkFormat(); 19 19 ?> 20 20 <style> … … 37 37 <h1>New York Times Bestseller Listings — Settings</h1> 38 38 <form method="post" action=""> 39 <?php wp_nonce_field( 'save-nyt-bestseller-settings', '_nyt-bestseller-listings-settings-nonce' ) ?>39 <?php wp_nonce_field( 'save-nyt-bestseller-settings', '_nyt-bestseller-listings-settings-nonce' ); ?> 40 40 41 41 <label class="block">API Key</label> 42 42 <p class="help">You can get one of these <a href="https://developer.nytimes.com/signup">here.</a></p> 43 <input type="text" class="wide" name="nyt_bestseller_listings_apiKey" value="<? = esc_attr($apiKey)?>">43 <input type="text" class="wide" name="nyt_bestseller_listings_apiKey" value="<?php echo esc_attr( $api_key ); ?>"> 44 44 45 45 46 46 <label class="block">Catalog Links</label> 47 47 <p class="help">You can add links to your library catalog to each book. Enter the catalog url below, using various placeholders to insert book variables. For example, settings this to <b>http://example.com/?serial={isbn}</b> would insert the book's isbn after the <b>serial=</b> in the resulting url. Leave this blank to hide links to a catalog.</p> 48 <input type="text" class="wide" value="<? = esc_attr($catalogLinkFormat)?>" name="nyt_bestseller_listings_CatalogLinkFormat">48 <input type="text" class="wide" value="<?php echo esc_attr( $catalog_link_format ); ?>" name="nyt_bestseller_listings_CatalogLinkFormat"> 49 49 <p class="help">Placeholders: <b>{isbn}</b>, <b>{title}</b>, <b>{author}</b></p> 50 50 51 <p> 52 <input type="submit" class="button-primary" value="Save" name="nyt-bestseller-listings-settings"> 53 </p> 51 <?php submit_button( 'Save', 'primary', 'nyt-bestseller-listings-settings' ); ?> 52 54 53 </form> -
bestseller-lists-from-new-york-times/trunk/functions.php
r2705840 r2967544 1 1 <?php 2 defined( 'ABSPATH') || die('Not allowed');2 defined( 'ABSPATH' ) || die( 'Not allowed' ); 3 3 4 4 5 function nytBestsellerListings_mainDisplay ($atts, $content){6 wp_enqueue_script( 'nyt-bestseller-listings');7 wp_enqueue_style( 'nyt-bestseller-listings');5 function NytBestsellerListings_mainDisplay ( $atts, $content ) { 6 wp_enqueue_script( 'nyt-bestseller-listings' ); 7 wp_enqueue_style( 'nyt-bestseller-listings' ); 8 8 9 if ( isset($atts['initialList']) )9 if ( isset( $atts['initialList'] ) ) 10 10 $atts['initial-list'] = $atts['initialList']; 11 11 12 12 $atts = shortcode_atts([ 13 'initial-list' => nytBestsellerListings::getDefaultList(),13 'initial-list' => NytBestsellerListings::getDefaultList(), 14 14 'displayImages' => '1', 15 15 ], $atts, 'nyt_bestseller_listings' ); 16 16 17 if ( isset($_GET['nytlist']) )18 $atts['initial-list'] = $_GET['nytlist'];17 if ( isset( $_GET['nytlist'] ) ) 18 $atts['initial-list'] = sanitize_text_field( $_GET['nytlist'] ); 19 19 20 if ( $atts['displayImages']==='1') {21 $display Images = true;22 $display ImagesJs = "true";20 if ( $atts['displayImages'] === '1' ) { 21 $display_images = true; 22 $display_images_js = 'true'; 23 23 } else { 24 $display Images = false;25 $display ImagesJs = "false";24 $display_images = false; 25 $display_images_js = 'false'; 26 26 } 27 27 28 $js = <<<JS28 $js = ' 29 29 bslnyt = window.bslnyt || {}; 30 bslnyt.displayImages = ' . esc_js( $display_images_js ) . '; 31 '; 30 32 31 bslnyt.displayImages = $displayImagesJs; 32 JS; 33 wp_add_inline_script('nyt-bestseller-listings', $js, 'before' ); 33 wp_add_inline_script( 'nyt-bestseller-listings', $js, 'before' ); 34 34 35 $dropdown = nytBestsellerListings::getListsDropdown( $atts['initial-list'] );35 $dropdown = NytBestsellerListings::getListsDropdown( $atts['initial-list'] ); 36 36 37 if ( $dropdown) :38 $out = $dropdown 37 if ( ! empty( $dropdown ) ) : 38 $out = $dropdown 39 39 . '<div class="nyt-bestseller-listings-booklist">' 40 . nytBestsellerListings::getBookList( $atts['initial-list'], false, $displayImages )41 . '</div>' 40 . NytBestsellerListings::getBookList( $atts['initial-list'], true, $display_images ) 41 . '</div>' 42 42 . $dropdown; 43 43 else : … … 46 46 47 47 return $out; 48 49 48 } -
bestseller-lists-from-new-york-times/trunk/index.php
r2955023 r2967544 4 4 Plugin URI: https://jakeparis.com/wordpress-plugins/ 5 5 Description: Integrate bestseller lists from the New York Times into your own site with a user-friendly interface. 6 Version: 2. 2.07 Requires PHP: 5.48 Requires at least: 4.96 Version: 2.3.0 7 Requires PHP: 7.4 8 Requires at least: 5.4 9 9 Tested up to: 6.3.0 10 10 Author: Jake Paris … … 13 13 License URI: https://opensource.org/licenses/GPL-3.0 14 14 */ 15 defined( 'ABSPATH' ) || die( 'Not allowed' ); 15 16 16 define( 'BSLNYT_PLUGIN_VERSION', '2.2.0');17 define( 'BSLNYT_PLUGIN_PATH', plugin_dir_path(__FILE__) );18 define( 'BSLNYT_PLUGIN_URL', plugins_url('/', __FILE__) );17 define( 'BSLNYT_PLUGIN_VERSION', '2.3.0' ); 18 define( 'BSLNYT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 19 define( 'BSLNYT_PLUGIN_URL', plugins_url( '/', __FILE__ ) ); 19 20 20 if( function_exists('register_block_type') )21 require_once BSLNYT_PLUGIN_PATH . 'blocks/block-registration.php';22 21 23 require_once BSLNYT_PLUGIN_PATH . ' nytBestsellerListings.class.php';22 require_once BSLNYT_PLUGIN_PATH . 'class-nytbestsellerlistings.php'; 24 23 require_once BSLNYT_PLUGIN_PATH . 'functions.php'; 25 24 26 require_once BSLNYT_PLUGIN_PATH . 'plugin _updates.php';25 require_once BSLNYT_PLUGIN_PATH . 'plugin-updates.php'; 27 26 28 add_action('wp_enqueue_scripts', function(){29 wp_register_script( 'nyt-bestseller-listings', 30 BSLNYT_PLUGIN_URL . ' public-assets/build/nyt-bestseller-listings.js',27 add_action('wp_enqueue_scripts', function () { 28 wp_register_script( 'nyt-bestseller-listings', 29 BSLNYT_PLUGIN_URL . 'build/ui/public.js', 31 30 array( 32 'jquery' 33 ), 31 'jquery', 32 ), 34 33 BSLNYT_PLUGIN_VERSION 35 34 ); 36 wp_register_style ( 'nyt-bestseller-listings',37 BSLNYT_PLUGIN_URL . ' public-assets/build/nyt-bestseller-listings.css',35 wp_register_style( 'nyt-bestseller-listings', 36 BSLNYT_PLUGIN_URL . 'build/ui/public.css', 38 37 array(), 39 38 BSLNYT_PLUGIN_VERSION 40 39 ); 41 40 42 if( ! empty($_SERVER['HTTPS']) ) 43 $js_args = array('ajaxurl' => admin_url( 'admin-ajax.php','https' ) ); 44 else 45 $js_args = array('ajaxurl' => admin_url( 'admin-ajax.php','http' ) ); 41 if ( ! empty( $_SERVER['HTTPS'] ) ) { 42 $js_args = array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'https' ) ); 43 } else { 44 $js_args = array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'http' ) ); 45 } 46 46 wp_localize_script( 'nyt-bestseller-listings', 'nyt_bestseller_listings_settings', $js_args ); 47 47 }); 48 48 49 49 50 add_action('init',function(){ 51 add_shortcode( 'nyt-bestseller-listings', 'nytBestsellerListings_mainDisplay'); 50 add_action('init', function () { 51 add_shortcode( 'nyt-bestseller-listings', function ( $atts, $content ) { 52 return wp_kses_post( NytBestsellerListings_mainDisplay( $atts, $content ) ); 53 }); 54 55 register_block_type( BSLNYT_PLUGIN_PATH . 'build/lists/block.json' ); 52 56 }); 53 57 54 add_action('admin_menu',function(){ 58 59 add_action('admin_menu', function () { 55 60 add_options_page( 'NYT Bestseller Lists', 'NYT Bestseller Lists', 'activate_plugins', 'nyt-bestseller-lists', 'nytBestSellerListings_adminPage' ); 56 61 }); 57 62 58 function nytBestSellerListings_adminPage() {63 function nytBestSellerListings_adminPage() { 59 64 require_once BSLNYT_PLUGIN_PATH . 'admin-page.php'; 60 65 } 61 66 62 67 63 add_action( 'wp_ajax_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList');64 add_action( 'wp_ajax_nopriv_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList');65 function nytBestSellerListings_ajax_getList() {66 $list = $_REQUEST['listName'];68 add_action( 'wp_ajax_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList' ); 69 add_action( 'wp_ajax_nopriv_nyt_bestseller_listings_getList', 'nytBestSellerListings_ajax_getList' ); 70 function nytBestSellerListings_ajax_getList() { 71 $list = sanitize_text_field( $_GET['listName'] ); 67 72 68 $display Images = ( isset($_REQUEST['displayImages']) )69 ? (bool) $_ REQUEST['displayImages']73 $display_images = ( isset( $_GET['displayImages'] ) ) 74 ? (bool) $_GET['displayImages'] 70 75 : true; 71 76 72 $html = nytBestsellerListings::getBookList( $list, false, $displayImages );73 echo $html;77 $html = NytBestsellerListings::getBookList( $list, true, $display_images ); 78 echo wp_kses_post( $html ); 74 79 exit; 75 80 } 76 81 82 add_action( 'wp_ajax_nyt_bestseller_listings_getAllLists', 'nytBestSellerListings_ajax_getAllLists' ); 83 add_action( 'wp_ajax_nopriv_nyt_bestseller_listings_getAllLists', 'nytBestSellerListings_ajax_getAllLists' ); 84 function nytBestSellerListings_ajax_getAllLists () { 85 $all_lists = NytBestsellerListings::getResults( 'names.json' ); 86 $all_lists_configured = []; 87 if ( ! empty( $all_lists ) ) { 88 foreach ( $all_lists->results as $list ) { 89 $all_lists_configured[] = [ 90 'label' => $list->display_name, 91 'value' => $list->list_name_encoded, 92 ]; 93 } 94 } 95 wp_send_json_success( $all_lists_configured ); 96 } 77 97 78 register_deactivation_hook(__FILE__, function (){79 delete_option( 'nyt_bestseller_listings_apiKey');80 delete_option( 'nyt_bestseller_listings_defaultList');98 register_deactivation_hook(__FILE__, function () { 99 delete_option( 'nyt_bestseller_listings_apiKey' ); 100 delete_option( 'nyt_bestseller_listings_defaultList' ); 81 101 }); -
bestseller-lists-from-new-york-times/trunk/readme.txt
r2955023 r2967544 3 3 Donate link: https://jakeparis.com/ 4 4 Tags: books, library, bestsellers, libraries, reading lists 5 Requires at least: 4.95 Requires at least: 5.4 6 6 Tested up to: 6.3.0 7 7 Stable tag: 2.2.0 … … 46 46 47 47 == Changelog == 48 49 = 2.3.0 = 50 51 Reorganization of plugin; housekeeping. 48 52 49 53 = 2.2.0 =
Note: See TracChangeset
for help on using the changeset viewer.