| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; |
| 2 |
class Wow_Company{ |
| 3 |
public function __construct() { |
| 4 |
add_action( 'admin_menu', array($this, 'add_menu') ); |
| 5 |
add_action( 'plugins_loaded', array($this, 'plugin_check') ); |
| 6 |
add_filter( 'admin_footer_text', array($this, 'admin_footer_text') ); |
| 7 |
} |
| 8 |
//register the plugin menu for backend. |
| 9 |
function add_menu() { |
| 10 |
add_menu_page('Wow-Company', 'Wow-Company', 'manage_options', 'wow-company', array($this, 'main_page'), plugin_dir_url( __FILE__ ) .'menu/icon.png'); |
| 11 |
add_submenu_page('wow-company', 'All Plugins', 'All Plugins', 'manage_options', 'wow-company'); |
| 12 |
} |
| 13 |
//menu page |
| 14 |
function main_page() { |
| 15 |
global $wow_plugin; |
| 16 |
$wow_plugin = true; |
| 17 |
include( 'menu/items.php' ); |
| 18 |
wp_enqueue_style('wow-company', plugin_dir_url(__FILE__) . 'menu/style.css'); |
| 19 |
} |
| 20 |
function plugin_check() { |
| 21 |
if (isset($_POST['wow_plugin_nonce_field'])) { |
| 22 |
if ( !empty($_POST) && wp_verify_nonce($_POST['wow_plugin_nonce_field'],'wow_plugin_action') && current_user_can('manage_options')){ |
| 23 |
self:: save_data(); |
| 24 |
} |
| 25 |
} |
| 26 |
} |
| 27 |
function save_data(){ |
| 28 |
global $wpdb; |
| 29 |
$objItem = new WOW_DATA(); |
| 30 |
$add = (isset($_REQUEST["add"])) ? sanitize_text_field($_REQUEST["add"]) : ''; |
| 31 |
$data = (isset($_REQUEST["data"])) ? sanitize_text_field($_REQUEST["data"]) : ''; |
| 32 |
$page = sanitize_text_field($_REQUEST["page"]); |
| 33 |
$id = absint($_POST['id']); |
| 34 |
if (isset($_POST["submit"])) { |
| 35 |
if (sanitize_text_field($_POST["add"]) == "1") { |
| 36 |
$objItem->addNewItem($data, $_POST); |
| 37 |
header("Location:admin.php?page=".$page."&info=saved"); |
| 38 |
exit; |
| 39 |
} |
| 40 |
else if (sanitize_text_field($_POST["add"]) == "2") { |
| 41 |
$objItem->updItem($data, $_POST); |
| 42 |
header("Location:admin.php?page=".$page."&tool=add&act=update&id=".$id."&info=update"); |
| 43 |
exit; |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
function admin_footer_text( $footer_text ) { |
| 48 |
global $wow_company_plugin; |
| 49 |
if ( $wow_company_plugin == true ) { |
| 50 |
$rate_text = sprintf( '<span id="footer-thankyou">Developed by <a href="https://wow-estore.com/author/admin/?author_downloads=true" target="_blank">Wow-Company</a> | <a href="https://www.facebook.com/wowaffect/" target="_blank">Join us on Facebook</a></span>'); |
| 51 |
return str_replace( '</span>', '', $footer_text ) . ' | ' . $rate_text . '</span>'; |
| 52 |
} |
| 53 |
else { |
| 54 |
return $footer_text; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
$Wow_Company = new Wow_Company(); |