| 1 |
<?php |
| 2 |
add_action( 'admin_menu', 'wp_insert_admin_menu' ); |
| 3 |
add_action( 'plugin_action_links_wp-insert/wp-insert.php', 'wp_insert_plugin_action_links' ); |
| 4 |
function wp_insert_plugin_action_links( $links ) { |
| 5 |
$links = array_merge( |
| 6 |
[ '<a href="' . esc_url( admin_url( '/admin.php?page=wp-insert' ) ) . '">Settings</a>' ], |
| 7 |
$links |
| 8 |
); |
| 9 |
return $links; |
| 10 |
} |
| 11 |
|
| 12 |
function wp_insert_admin_menu() { |
| 13 |
add_menu_page( 'Wp Insert', 'Wp Insert', 'manage_options', 'wp-insert', 'wp_insert_admin_page', WP_INSERT_URL . '/includes/assets/images/icon.png' ); |
| 14 |
} |
| 15 |
|
| 16 |
add_action( 'admin_enqueue_scripts', 'wp_insert_admin_enqueue_scripts', 99999 ); |
| 17 |
function wp_insert_admin_enqueue_scripts( $page ) { |
| 18 |
wp_register_script( 'wp-insert-global-js', WP_INSERT_URL . 'includes/assets/js/wp-insert-global.js', [ 'jquery' ], WP_INSERT_VERSION, true ); |
| 19 |
wp_enqueue_script( 'wp-insert-global-js' ); |
| 20 |
if ( $page == 'toplevel_page_wp-insert' ) { |
| 21 |
wp_register_style( 'wp-insert-css', WP_INSERT_URL . 'includes/assets/css/wp-insert.css', [], WP_INSERT_VERSION . wp_rand( 0, 9999 ) ); |
| 22 |
wp_enqueue_style( 'wp-insert-css' ); |
| 23 |
wp_register_style( 'wp-insert-jquery-ui', WP_INSERT_URL . 'includes/assets/css/jquery-ui/jquery-ui.min.css', [], WP_INSERT_VERSION ); |
| 24 |
wp_enqueue_style( 'wp-insert-jquery-ui' ); |
| 25 |
wp_register_script( 'wp-insert-js', WP_INSERT_URL . 'includes/assets/js/wp-insert.js', [ 'jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-dialog' ], WP_INSERT_VERSION . wp_rand( 0, 9999 ), true ); |
| 26 |
wp_enqueue_script( 'wp-insert-js' ); |
| 27 |
wp_register_script( 'chart-js', WP_INSERT_URL . 'includes/assets/js/Chart.bundle.min.js', [ 'jquery' ], WP_INSERT_VERSION, true ); |
| 28 |
wp_enqueue_script( 'chart-js' ); |
| 29 |
do_action( 'wp_insert_modules_css' ); |
| 30 |
do_action( 'wp_insert_modules_js' ); |
| 31 |
smartlogixControls::enqueue_assets( WP_INSERT_URL . 'includes/modules/core/controls', WP_INSERT_VERSION ); |
| 32 |
wp_enqueue_script( 'editor' ); |
| 33 |
wp_enqueue_script( 'quicktags' ); |
| 34 |
wp_enqueue_style( 'buttons' ); |
| 35 |
/*Page Links To Plugin incompatible code override*/ |
| 36 |
wp_dequeue_style( 'wp-jquery-ui-dialog' ); |
| 37 |
wp_dequeue_script( 'plt-quick-add' ); |
| 38 |
wp_dequeue_style( 'plt-quick-add' ); |
| 39 |
wp_deregister_style( 'wp-jquery-ui-dialog' ); |
| 40 |
wp_deregister_script( 'plt-quick-add' ); |
| 41 |
wp_deregister_style( 'plt-quick-add' ); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
function wp_insert_admin_page() { |
| 46 |
?> |
| 47 |
<div class="wrap wp-insert"> |
| 48 |
<h2 id="wp_insert_title" style="display: none;"></h2> |
| 49 |
<div class="wp-list-table widefat plugin-install"> |
| 50 |
<?php do_action( 'wp_insert_plugin_card' ); ?> |
| 51 |
<input type="hidden" id="wp_insert_admin_ajax" name="wp_insert_admin_ajax" value="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" /> |
| 52 |
<input type="hidden" id="wp_insert_nonce" name="wp_insert_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wp-insert' ) ); ?>" /> |
| 53 |
</div> |
| 54 |
</div> |
| 55 |
<?php |
| 56 |
} |
| 57 |
|
| 58 |
/* Begin Add Card in Admin Panel */ |
| 59 |
add_action( 'wp_insert_plugin_card', 'wp_insert_title_plugin_card', 0 ); |
| 60 |
function wp_insert_title_plugin_card() { |
| 61 |
echo '<div class="plugin-card">'; |
| 62 |
echo '<div class="plugin-card-top">'; |
| 63 |
echo '<a id="wpInsertLogo" href="https://www.wpinsert.smartlogix.co.in"><img src="' . esc_url( WP_INSERT_URL . '/includes/assets/images/header-banner.png?' . WP_INSERT_VERSION ) . '" alt="Wp-Insert" /></a>'; |
| 64 |
echo '</div>'; |
| 65 |
echo '<div class="plugin-card-bottom">'; |
| 66 |
echo '<div id="wpInsertMeta">'; |
| 67 |
echo '<p><b>Donate :</b><br /><a target="_blank" href="https://wpinsert.smartlogix.co.in/support/">Click Here</a> to Donate and Promote further development of this plugin.</p>'; |
| 68 |
echo '<p><b>Like Us :</b><br /><a target="_blank" href="https://www.facebook.com/SmartLogix/">Click here</a> to like and support us on Facebook</p>'; |
| 69 |
echo '<div style="font-size: 16px; font-weight: 600; background: #FFFFAA; display: block; padding: 10px; text-align: justify; border: 1px dashed #FF0000; margin: 10px 0 0; border-radius: 5px;">Thanks for using Wp-Insert. Positive <a target="_blank" href="https://wordpress.org/support/view/plugin-reviews/wp-insert#postform">reviews</a> are a great motivation for us to add new features, fix bugs and spend more time working on Wp-Insert.<br />Looking forward to your continued support and patronage - <i>Namith Jawahar</i>.</div>'; |
| 70 |
echo '</div>'; |
| 71 |
echo '</div>'; |
| 72 |
echo '</div>'; |
| 73 |
} |
| 74 |
/* End Add Card in Admin Panel */ |
| 75 |
|
| 76 |
/* Begin Admin Notice */ |
| 77 |
add_action( 'wp_ajax_wp_insert_admin_notice_dismiss', 'wp_insert_admin_notice_dismiss' ); |
| 78 |
function wp_insert_admin_notice_dismiss() { |
| 79 |
check_ajax_referer( 'wp-insert-admin-notice', 'wp_insert_admin_notice_nonce' ); |
| 80 |
$userId = get_current_user_id(); |
| 81 |
update_user_meta( $userId, 'wp_insert_2.3_admin_notice_dismissed', 'true' ); |
| 82 |
wp_die(); |
| 83 |
} |
| 84 |
/* End Admin Notice */ |
| 85 |
?> |
| 86 |
|