| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> |
| 2 |
<?php |
| 3 |
/* |
| 4 |
Plugin Name: YYDevelopment - Page & Post Notes |
| 5 |
Plugin URI: https://www.yydevelopment.com/yydevelopment-wordpress-plugins/ |
| 6 |
Description: Simple plugin that allow you to notes on pages and posts |
| 7 |
Version: 1.3.2 |
| 8 |
Author: YYDevelopment |
| 9 |
Author URI: https://www.yydevelopment.com/ |
| 10 |
*/ |
| 11 |
|
| 12 |
include_once('include/settings.php'); |
| 13 |
require_once('include/functions.php'); |
| 14 |
|
| 15 |
// ================================================ |
| 16 |
// Creating Database when the plugin is activated |
| 17 |
// ================================================ |
| 18 |
|
| 19 |
function yydev_notes_create_database() { |
| 20 |
|
| 21 |
require_once('include/install.php'); |
| 22 |
|
| 23 |
} // function yydev_notes_create_database() { |
| 24 |
|
| 25 |
register_activation_hook(__FILE__, 'yydev_notes_create_database'); // run on plugin update |
| 26 |
|
| 27 |
// ================================================ |
| 28 |
// display the plugin we have create on the wordpress |
| 29 |
// post blog and pages |
| 30 |
// ================================================ |
| 31 |
|
| 32 |
// function that will output the code to the page |
| 33 |
function yydev_notes_output_plugin($term) { |
| 34 |
|
| 35 |
include('include/style.php'); |
| 36 |
include('include/script.php'); |
| 37 |
include('include/admin-output.php'); |
| 38 |
|
| 39 |
} // function yydev_notes_output_plugin() { |
| 40 |
|
| 41 |
function yydev_notes_register_meta_boxes() { |
| 42 |
add_meta_box( 'yydev_notes', 'Page Notes', 'yydev_notes_output_plugin',null ,'side'); |
| 43 |
} // function yydev_notes_register_meta_boxes() { |
| 44 |
|
| 45 |
add_action( 'add_meta_boxes', 'yydev_notes_register_meta_boxes' ); |
| 46 |
|
| 47 |
// ================================================ |
| 48 |
// Adding the comments to the dashboard page |
| 49 |
// ================================================ |
| 50 |
|
| 51 |
// function that will output the code to the page |
| 52 |
function yydev_notes_output_plugin_dashbaord($term) { |
| 53 |
|
| 54 |
$yydev_notes_active_dashbaord = 1; |
| 55 |
|
| 56 |
include('include/style.php'); |
| 57 |
include('include/script.php'); |
| 58 |
include('include/admin-output.php'); |
| 59 |
|
| 60 |
} // function yydev_notes_output_plugin() { |
| 61 |
|
| 62 |
function yydev_notes_dashboard_widgets() { |
| 63 |
wp_add_dashboard_widget('yydevelopment_notes', 'Dashboard Notes', 'yydev_notes_output_plugin_dashbaord'); |
| 64 |
} // function yydev_notes_dashboard_widgets() { |
| 65 |
|
| 66 |
add_action('wp_dashboard_setup', 'yydev_notes_dashboard_widgets'); |
| 67 |
|
| 68 |
// ================================================ |
| 69 |
// function that will insert the code to the datbase |
| 70 |
// once the post or page is updated |
| 71 |
// ================================================ |
| 72 |
|
| 73 |
function yydev_notes_insert_to_database() { |
| 74 |
|
| 75 |
include('include/insert-to-db.php'); |
| 76 |
|
| 77 |
} // function yydev_notes_insert_to_database() { |
| 78 |
|
| 79 |
add_action('pre_post_update', 'yydev_notes_insert_to_database'); |
| 80 |
|
| 81 |
// ================================================ |
| 82 |
// ajax function to save the data in the database |
| 83 |
// ================================================ |
| 84 |
|
| 85 |
function yydev_notes_save_dashboard_data() { |
| 86 |
|
| 87 |
include('include/insert-to-db.php'); |
| 88 |
echo "Saved"; |
| 89 |
die(); // we have to end ajax functions with die(); |
| 90 |
|
| 91 |
} // function yydev_notes_save_dashboard_data() { |
| 92 |
|
| 93 |
add_action( 'wp_ajax_yydev_notes_save_dashboard_data', 'yydev_notes_save_dashboard_data' ); // create ajax function we can call with javascript |
| 94 |
add_action( 'wp_ajax_nopriv_yydev_notes_save_dashboard_data', 'yydev_notes_save_dashboard_data' ); // add access for users who are not logged in |
| 95 |
|
| 96 |
// ================================================ |
| 97 |
// Add donate page to the plugin menu info |
| 98 |
// ================================================ |
| 99 |
|
| 100 |
add_filter( 'plugin_action_links', function($actions, $plugin_file) { |
| 101 |
|
| 102 |
static $plugin; |
| 103 |
|
| 104 |
if (!isset($plugin)) { $plugin = plugin_basename(__FILE__); } |
| 105 |
|
| 106 |
if ($plugin == $plugin_file) { |
| 107 |
|
| 108 |
$admin_page_url = esc_url( menu_page_url( 'page-post-notes', false ) ); |
| 109 |
$donate = array('donate' => '<a target="_blank" href="https://www.yydevelopment.com/coffee-break/?plugin=page-post-notes">Donate</a>'); |
| 110 |
|
| 111 |
$actions = array_merge($donate, $actions); |
| 112 |
|
| 113 |
} // if ($plugin == $plugin_file) { |
| 114 |
|
| 115 |
return $actions; |
| 116 |
|
| 117 |
}, 10, 5 ); |
| 118 |
|
| 119 |
// ================================================ |
| 120 |
// including admin notices flie |
| 121 |
// ================================================ |
| 122 |
|
| 123 |
if( is_admin() ) { |
| 124 |
include_once('notices.php'); |
| 125 |
} // if( is_admin() ) { |