/index.php

  1. <?php 
  2. /** 
  3. Plugin Name: Google Books Importer 
  4. Plugin URI: https://firescripts.net 
  5. Description: Bulk import of books from Google Books 
  6. Version: 1.3 
  7. Author: Zarko 
  8. Author URI: https://firescripts.net 
  9. License: GPLv3 
  10. */ 
  11.  
  12. define('GBI_PATH', dirname(__FILE__)); 
  13. define('GBI_URL', plugin_dir_url(__FILE__)); 
  14.  
  15. add_action('admin_menu', 'gbi_register_submenu_page'); 
  16. add_action('admin_init', 'gbi_register_resources'); 
  17. add_action('admin_init', 'gbi_default_setup'); 
  18.  
  19. include('inc/functions.php'); 
  20.  
  21. function gbi_register_submenu_page() { 
  22. add_menu_page('Google Books Importer', 'GB Import', 'manage_options', 'google-books-importer', 'gbi_admin_pages', 'dashicons-book-alt'); 
  23. add_submenu_page( 'google-books-importer', 'Google Books Importer Settings', 'GB Settings', 'manage_options', 'google-books-settings', 'gbi_admin_pages');  
  24.  
  25. function gbi_admin_pages() {  
  26. require_once(GBI_PATH.'/admin.php'); 
  27.  
  28. // include resources 
  29. function gbi_register_resources() {  
  30. if(isset($_GET['page']) && ($_GET['page'] == 'google-books-importer' || $_GET['page'] == 'google-books-settings')) {  
  31. wp_enqueue_style('gbi-style', GBI_URL.'assets/style.css'); 
  32. wp_enqueue_script('gbi-script', GBI_URL.'assets/scripts.js', array('jquery')); 
  33.  
  34. function gbi_default_setup() {  
  35.  
  36. if(get_option('gbi_fields')) 
  37. return; 
  38.  
  39. // default setup 
  40. $mapped_fields = array(  
  41. 'post_title' => 'title',  
  42. 'post_content' => 'description',  
  43. 'post_excerpt' => 'subtitle',  
  44. 'post_status' => 'publish',  
  45. 'comment_status' => 'open',  
  46. 'post_types' => 'post',  
  47. 'category' => '0',  
  48. 'featured' => '0',  
  49. ); 
  50.  
  51. update_option('gbi_fields', $mapped_fields); 
  52. update_option('gbi_apikey', ''); 
  53.  
.