| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin main page |
| 4 |
* |
| 5 |
* @package Wow_Plugin |
| 6 |
* @subpackage Admin/Main_page |
| 7 |
* @author Wow-Company <helper@wow-company.com> |
| 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 |
'settings' => 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 |
'tools' => esc_attr__( 'Import/Export', $this->plugin['text'] ), |
| 38 |
'rate' => esc_attr__( 'Rate', $this->plugin['text'] ), |
| 39 |
) ); |
| 40 |
|
| 41 |
$rate_url = 'https://wordpress.org/support/plugin/float-menu/reviews/#new-post'; |
| 42 |
|
| 43 |
$rating = $this->rating['wp_url']; |
| 44 |
?> |
| 45 |
|
| 46 |
<div class="wrap"> |
| 47 |
<h1 class="wp-heading-inline"><?php echo esc_attr( $this->plugin['name'] ); ?> |
| 48 |
v. <?php echo esc_attr( $this->plugin['version'] ); ?></h1> |
| 49 |
<a href="?page=<?php echo esc_attr( $this->plugin['slug'] ); ?>&tab=settings" class="page-title-action"> |
| 50 |
<?php esc_attr_e( 'Add New', $this->plugin['text'] ); ?></a> |
| 51 |
<hr class="wp-header-end"> |
| 52 |
<?php if ( get_option( 'wow_' . $this->plugin['prefix'] . '_message' ) != 'read' ) : ?> |
| 53 |
<div class="notice notice-info is-dismissible wow-plugin-message"> |
| 54 |
<p class="ideas"> |
| 55 |
<i class="fas fa-bullhorn"></i>We are constantly trying to improve the plugin and add more useful |
| 56 |
features to it. Your support and your ideas for improving the plugin are very important to us. <br/> |
| 57 |
<i class="fas fa-star"></i>If you like the plugin, please <a |
| 58 |
href="<?php echo esc_url( $rating ); ?>" target="_blank">leave a review</a> about it at |
| 59 |
WordPress.org. |
| 60 |
|
| 61 |
</p> |
| 62 |
</div> |
| 63 |
<?php endif; ?> |
| 64 |
|
| 65 |
<div id="wow-message"></div> |
| 66 |
|
| 67 |
<?php |
| 68 |
echo '<h2 class="nav-tab-wrapper">'; |
| 69 |
foreach ( $tabs as $tab => $name ) { |
| 70 |
$class = ( $tab === $current_tab ) ? ' nav-tab-active' : ''; |
| 71 |
if ( $tab === 'options' ) { |
| 72 |
$action = ( isset( $_REQUEST["act"] ) ) ? sanitize_text_field( $_REQUEST["act"] ) : ''; |
| 73 |
if ( ! empty( $action ) && $action == 'update' ) { |
| 74 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->plugin['slug'] ) . '&tab=' . |
| 75 |
esc_attr( $tab ) . '">' . esc_attr__( 'Update', $this->plugin['prefix'] ) . ' #' . |
| 76 |
absint( $_REQUEST["id"] ) . '</a>'; |
| 77 |
} else { |
| 78 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->plugin['slug'] ) . '&tab=' . |
| 79 |
esc_attr( $tab ) . '">' . esc_attr( $name ) . '</a>'; |
| 80 |
} |
| 81 |
} elseif ( $tab === 'extension' ) { |
| 82 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->plugin['slug'] ) . '&tab=' |
| 83 |
. esc_attr( $tab ) . '"><span class="dashicons dashicons-yes" style="color:#00d1b2;"></span> ' . esc_attr( $name ) . '</a>'; |
| 84 |
} elseif ( $tab === 'rate' ) { |
| 85 |
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>'; |
| 86 |
|
| 87 |
} elseif ( $tab === 'docs' ) { |
| 88 |
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>'; |
| 89 |
|
| 90 |
} else { |
| 91 |
echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->plugin['slug'] ) . '&tab=' . |
| 92 |
esc_attr( $tab ) . '">' . esc_attr( $name ) . '</a>'; |
| 93 |
} |
| 94 |
|
| 95 |
} |
| 96 |
echo '</h2>'; |
| 97 |
$file = array_key_exists( $current_tab, $tabs ) ? 'page-' . $current_tab : 'page-list'; |
| 98 |
include_once( $file . '.php' ); |
| 99 |
?> |
| 100 |
</div> |
| 101 |
<?php |
| 102 |
|