| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin main page |
| 4 |
* |
| 5 |
* @package Wow_Plugin |
| 6 |
* @subpackage Admin/Main_page |
| 7 |
* @author Dmytro Lobov <d@dayes.dev> |
| 8 |
* @copyright 2019 Wow-Company |
| 9 |
* @license GNU Public License |
| 10 |
* @version 1.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
global $wpdb; |
| 18 |
$data = $wpdb->prefix . 'wow_' . $this->plugin['prefix']; |
| 19 |
$info = ( isset( $_REQUEST['info'] ) ) ? sanitize_text_field( $_REQUEST['info'] ) : ''; |
| 20 |
if ( $info === 'saved' ) { |
| 21 |
echo '<div class="updated" id="message"><p><strong>' . esc_attr__( 'Item Added', $this->plugin['text'] ) . '</strong>.</p></div>'; |
| 22 |
} elseif ( $info === 'update' ) { |
| 23 |
echo '<div class="updated" id="message"><p><strong>' . esc_attr__( 'Item Updated', $this->plugin['text'] ) . '</strong>.</p></div>'; |
| 24 |
} elseif ( $info === 'delete' ) { |
| 25 |
$delid = absint( $_GET['did'] ); |
| 26 |
$wpdb->delete( $data, [ 'id' => $delid ], [ '%d' ] ); |
| 27 |
echo '<div class="updated" id="message"><p><strong>' . esc_attr__( 'Item Deleted', $this->plugin['text'] ) . '</strong>.</p></div>'; |
| 28 |
} |
| 29 |
|
| 30 |
$current_tab = ( isset( $_REQUEST["tab"] ) ) ? sanitize_text_field( $_REQUEST["tab"] ) : 'list'; |
| 31 |
|
| 32 |
$tabs = apply_filters( $this->plugin['slug'] . '_tab_menu', array( |
| 33 |
'list' => esc_attr__( 'List', $this->plugin['text'] ), |
| 34 |
'add-new' => esc_attr__( 'Add new', $this->plugin['text'] ), |
| 35 |
'extension' => esc_attr__( 'Pro Features', $this->plugin['text'] ), |
| 36 |
'support' => esc_attr__( 'Support', $this->plugin['text'] ), |
| 37 |
'items' => esc_attr__( 'Plugins', $this->plugin['text'] ), |
| 38 |
'rate' => esc_attr__( 'Rate', $this->plugin['text'] ), |
| 39 |
'docs' => esc_attr__( 'Documentation', $this->plugin['text'] ), |
| 40 |
) ); |
| 41 |
|
| 42 |
$rate_url = 'https://wordpress.org/support/plugin/float-menu/reviews/#new-post'; |
| 43 |
$docs_url = 'https://wow-company.com/faq/category/wow-plugins/float-menu-pro/'; |
| 44 |
|
| 45 |
$rating = $this->rating['wp_url']; |
| 46 |
?> |
| 47 |
|
| 48 |
<div class="wrap"> |
| 49 |
<h1 class="wp-heading-inline"><?php echo esc_attr( $this->plugin['name'] ); ?> |
| 50 |
v. <?php echo esc_attr( $this->plugin['version'] ); ?></h1> |
| 51 |
<a href="?page=<?php echo esc_attr( $this->plugin['slug'] ); ?>&tab=add-new" class="page-title-action"> |
| 52 |
<?php esc_attr_e( 'Add New', $this->plugin['text'] ); ?></a> |
| 53 |
|
| 54 |
<hr class="wp-header-end"> |
| 55 |
<div class="notice notice-info"> |
| 56 |
<p class="ideas"> |
| 57 |
<i class="fas fa-bullhorn"></i>We are constantly trying to improve the plugin and add more useful |
| 58 |
features to it. Your support and your ideas for improving the plugin are very important to us. <br/> |
| 59 |
<i class="fas fa-star"></i>If you like the plugin, please <a href="<?php echo esc_url( $rating ); ?>" |
| 60 |
target="_blank">leave a review</a> about it |
| 61 |
at WordPress.org.<br/> |
| 62 |
<i class="fas fa-share-alt"></i>Help other users find this plugin and take advantage of it. |
| 63 |
<b>Share:</b> <span data-share="facebook">Facebook</span>, <span data-share="twitter">Twitter</span>, |
| 64 |
<span data-share="vk">VK</span>, <span data-share="linkedin">LinkedIn</span>, <span |
| 65 |
data-share="pinterest">Pinterest</span>, <span data-share="xing">XING</span>, <span |
| 66 |
data-share="reddit">Reddit</span>, <span data-share="blogger">Blogger</span>, <span |
| 67 |
data-share="telegram">Telegram</span> |
| 68 |
</p> |
| 69 |
<input type="hidden" id="wp-title" value="<?php echo esc_attr( $this->rating['wp_title'] ); ?>"> |
| 70 |
<input type="hidden" id="wp-url" value="<?php echo esc_url( $this->rating['wp_home'] ); ?>"> |
| 71 |
</div> |
| 72 |
|
| 73 |
<div id="wow-message"></div> |
| 74 |
|
| 75 |
<?php |
| 76 |
echo '<h2 class="nav-tab-wrapper">'; |
| 77 |
foreach ( $tabs as $tab => $name ) { |
| 78 |
$class = ( $tab === $current_tab ) ? ' nav-tab-active' : ''; |
| 79 |
if ( $tab == 'add-new' ) { |
| 80 |
$action = ( isset( $_REQUEST["act"] ) ) ? sanitize_text_field( $_REQUEST["act"] ) : ''; |
| 81 |
if ( ! empty( $action ) && $action == 'update' ) { |
| 82 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->plugin['slug'] ) . '&tab=' |
| 83 |
. esc_attr( $tab ) . '">' . esc_attr__( 'Update', $this->plugin['prefix'] ) . ' #' |
| 84 |
. absint( $_REQUEST["id"] ) . '</a>'; |
| 85 |
} else { |
| 86 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr($this->plugin['slug']) . '&tab=' |
| 87 |
. esc_attr( $tab ) . '">' . esc_attr( $name ) . '</a>'; |
| 88 |
} |
| 89 |
} elseif ( $tab === 'rate' ) { |
| 90 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="' . esc_url( $rate_url ) . '" target="_blank"><span class="dashicons dashicons-star-filled" style="color:#ffcc01;"></span> ' . esc_attr( $name ) . '</a>'; |
| 91 |
|
| 92 |
} elseif ( $tab === 'docs' ) { |
| 93 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="' . esc_url( $docs_url ) . '" target="_blank"><span class="dashicons dashicons-media-document" style="color:#006bb3;"></span>' . esc_attr( $name ) . '</a>'; |
| 94 |
|
| 95 |
} else { |
| 96 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->plugin['slug'] ) . '&tab=' |
| 97 |
. esc_attr( $tab ) . '">' . esc_attr( $name ) . '</a>'; |
| 98 |
} |
| 99 |
|
| 100 |
} |
| 101 |
echo '</h2>'; |
| 102 |
$file = apply_filters( $this->plugin['slug'] . '_menu_file', $current_tab ); |
| 103 |
switch ( $file ) { |
| 104 |
case 'add-new': |
| 105 |
include_once( 'add-new.php' ); |
| 106 |
break; |
| 107 |
case 'extension': |
| 108 |
include_once( 'extension.php' ); |
| 109 |
break; |
| 110 |
case 'support': |
| 111 |
include_once( 'support.php' ); |
| 112 |
break; |
| 113 |
case 'items': |
| 114 |
include_once( 'items.php' ); |
| 115 |
break; |
| 116 |
default: |
| 117 |
include_once( 'list.php' ); |
| 118 |
break; |
| 119 |
} |
| 120 |
?> |
| 121 |
</div> |
| 122 |
<?php |
| 123 |
|