| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> |
| 2 |
<?php |
| 3 |
/* |
| 4 |
Plugin Name: YYDevelopment - Fast Whatsapp Chat Button |
| 5 |
Plugin URI: https://www.yydevelopment.com/yydevelopment-wordpress-plugins/ |
| 6 |
Description: Simple plugin that allow you add whatsapp chat button to your site |
| 7 |
Version: 2.1.1 |
| 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 |
|
| 20 |
function yydev_chat_btn_create_database() { |
| 21 |
|
| 22 |
require_once('include/install.php'); |
| 23 |
|
| 24 |
} // function yydev_chat_btn_create_database() { |
| 25 |
|
| 26 |
register_activation_hook(__FILE__, 'yydev_chat_btn_create_database'); |
| 27 |
|
| 28 |
// ================================================ |
| 29 |
// display the plugin we have create on the wordpress |
| 30 |
// post blog and pages |
| 31 |
// ================================================ |
| 32 |
|
| 33 |
// function that will output the code to the page |
| 34 |
function output_yydev_chat_btn() { |
| 35 |
|
| 36 |
include('include/style.php'); |
| 37 |
include('include/scripts.php'); |
| 38 |
include('include/admin-output.php'); |
| 39 |
|
| 40 |
} // function output_yydev_chat_btn() { |
| 41 |
|
| 42 |
// ----------------------------------------------- |
| 43 |
// load the page into settings page |
| 44 |
// ----------------------------------------------- |
| 45 |
|
| 46 |
// in case of settings menu loading |
| 47 |
function register_yydev_chat_btn_page() { |
| 48 |
add_options_page( 'Fast Whatsapp Button', "Fast Whatsapp Button", 'manage_options', 'yydev-chat-btn', 'output_yydev_chat_btn'); |
| 49 |
} // function register_yydev_chat_btn_page() { |
| 50 |
|
| 51 |
add_action('admin_menu', 'register_yydev_chat_btn_page'); |
| 52 |
|
| 53 |
// ================================================ |
| 54 |
// Add settings page to the plugin menu info |
| 55 |
// ================================================ |
| 56 |
|
| 57 |
function yydev_chat_btn_add_settings_link( $actions, $plugin_file ) { |
| 58 |
static $plugin; |
| 59 |
|
| 60 |
if (!isset($plugin)) { $plugin = plugin_basename(__FILE__); } |
| 61 |
if ($plugin == $plugin_file) { |
| 62 |
$admin_page_url = esc_url( menu_page_url( 'yydev-chat-btn', false ) ); |
| 63 |
$settings = array('settings' => '<a href="' . $admin_page_url . '">Settings</a>'); |
| 64 |
$actions = array_merge($settings, $actions); |
| 65 |
} // if ($plugin == $plugin_file) { |
| 66 |
return $actions; |
| 67 |
} //function yydev_chat_btn_add_settings_link( $actions, $plugin_file ) { |
| 68 |
|
| 69 |
add_filter( 'plugin_action_links', 'yydev_chat_btn_add_settings_link', 10, 5 ); |
| 70 |
|
| 71 |
// ================================================ |
| 72 |
// output the data into the page front end |
| 73 |
// ================================================ |
| 74 |
|
| 75 |
if( !is_admin() ) { |
| 76 |
include('include/front-end-output.php'); |
| 77 |
} // if( !is_admin() ) { |
| 78 |
|
| 79 |
// ================================================ |
| 80 |
// Add donate page to the plugin menu info |
| 81 |
// ================================================ |
| 82 |
|
| 83 |
add_filter( 'plugin_action_links', function($actions, $plugin_file) { |
| 84 |
|
| 85 |
static $plugin; |
| 86 |
|
| 87 |
if (!isset($plugin)) { $plugin = plugin_basename(__FILE__); } |
| 88 |
|
| 89 |
if ($plugin == $plugin_file) { |
| 90 |
|
| 91 |
$admin_page_url = esc_url( menu_page_url( 'yydevelopment-seo-data', false ) ); |
| 92 |
$donate = array('donate' => '<a target="_blank" href="https://www.yydevelopment.com/coffee-break/?plugin=fast-chat-button">Donate</a>'); |
| 93 |
|
| 94 |
$actions = array_merge($donate, $actions); |
| 95 |
|
| 96 |
} // if ($plugin == $plugin_file) { |
| 97 |
|
| 98 |
return $actions; |
| 99 |
|
| 100 |
}, 10, 5 ); |
| 101 |
|
| 102 |
// ================================================ |
| 103 |
// including admin notices flie |
| 104 |
// ================================================ |
| 105 |
|
| 106 |
if( is_admin() ) { |
| 107 |
include_once('notices.php'); |
| 108 |
} // if( is_admin() ) { |