| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Ovation Elements |
| 4 |
* Plugin URI: |
| 5 |
* Description: Transform your site with captivating sliders. Perfect for beginners and advanced users. Create and customize with our ultimate slider plugin. |
| 6 |
* Version: 1.0.2 |
| 7 |
* Requires at least: 5.2 |
| 8 |
* Requires PHP: 7.2 |
| 9 |
* Author: pewilliams |
| 10 |
* Author URI: https://www.ovationthemes.com/ |
| 11 |
* License: GPL v2 or later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Text Domain: ovation-elements |
| 14 |
*/ |
| 15 |
|
| 16 |
if (!defined('ABSPATH')) { |
| 17 |
exit; // Exit if accessed directly. |
| 18 |
} |
| 19 |
|
| 20 |
define( 'OVA_ELEMS_FILE', __FILE__ ); |
| 21 |
define( 'OVA_ELEMS_BASE', plugin_basename( OVA_ELEMS_FILE ) ); |
| 22 |
define( 'OVA_ELEMS_DIR', plugin_dir_path( OVA_ELEMS_FILE ) ); |
| 23 |
define( 'OVA_ELEMS_URL', plugins_url( '/', OVA_ELEMS_FILE ) ); |
| 24 |
|
| 25 |
if( ! function_exists('get_plugin_data') ) { |
| 26 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 27 |
} |
| 28 |
|
| 29 |
$plugin_data = get_plugin_data( __FILE__ ); |
| 30 |
define( 'OVA_ELEMS_VER', $plugin_data['Version'] ); |
| 31 |
|
| 32 |
// Include necessary files |
| 33 |
include(plugin_dir_path(__FILE__) . 'includes/admin-settings.php'); |
| 34 |
include(plugin_dir_path(__FILE__) . 'includes/slider-shortcode.php'); |
| 35 |
|
| 36 |
// Enqueue styles and scripts |
| 37 |
function ova_elems_enqueue_scripts() { |
| 38 |
wp_enqueue_style('ova-elems-bootstrap-css', plugin_dir_url(__FILE__) . 'assets/css/bootstrap.min.css', array(), OVA_ELEMS_VER); |
| 39 |
} |
| 40 |
add_action('wp_enqueue_scripts', 'ova_elems_enqueue_scripts'); |
| 41 |
|
| 42 |
function ova_elems_admin_scripts($hook) { |
| 43 |
|
| 44 |
wp_enqueue_media(); |
| 45 |
wp_enqueue_style('ova-elems-bootstrap-css', plugin_dir_url(__FILE__) . 'assets/css/bootstrap.min.css', array(), OVA_ELEMS_VER); |
| 46 |
wp_enqueue_style('ova-elems-admin-css', plugin_dir_url(__FILE__) . 'assets/css/slider-admin.css', array(), OVA_ELEMS_VER); |
| 47 |
|
| 48 |
if ( $hook == 'admin_page_edit-slider-template-template1' ) { |
| 49 |
wp_enqueue_script('ova-elems-template-1-scripts', plugin_dir_url(__FILE__) . 'assets/js/admin/template-1-scripts.js', array('jquery'), OVA_ELEMS_VER, true); |
| 50 |
} elseif ( $hook == 'admin_page_edit-slider-template-template2' ) { |
| 51 |
wp_enqueue_script('ova-elems-template-2-scripts', plugin_dir_url(__FILE__) . 'assets/js/admin/template-2-scripts.js', array('jquery'), OVA_ELEMS_VER, true); |
| 52 |
} elseif ( $hook == 'admin_page_edit-slider-template-template3' ) { |
| 53 |
wp_enqueue_script('ova-elems-template-3-scripts', plugin_dir_url(__FILE__) . 'assets/js/admin/template-3-scripts.js', array('jquery'), OVA_ELEMS_VER, true); |
| 54 |
} elseif ( $hook == 'admin_page_edit-slider-template-template4' ) { |
| 55 |
wp_enqueue_script('ova-elems-template-4-scripts', plugin_dir_url(__FILE__) . 'assets/js/admin/template-4-scripts.js', array('jquery'), OVA_ELEMS_VER, true); |
| 56 |
wp_localize_script( |
| 57 |
'ova-elems-template-4-scripts', |
| 58 |
'ova_elems_template_script', |
| 59 |
array( |
| 60 |
'ajaxurl' => admin_url('admin-ajax.php') |
| 61 |
) |
| 62 |
); |
| 63 |
} elseif ( $hook == 'admin_page_edit-slider-template-template5' ) { |
| 64 |
wp_enqueue_script('ova-elems-template-5-scripts', plugin_dir_url(__FILE__) . 'assets/js/admin/template-5-scripts.js', array('jquery'), OVA_ELEMS_VER, true); |
| 65 |
} |
| 66 |
} |
| 67 |
add_action('admin_enqueue_scripts', 'ova_elems_admin_scripts'); |
| 68 |
|
| 69 |
function ova_elems_admin_enqueue_scripts($hook_suffix) { |
| 70 |
if ($hook_suffix !== 'toplevel_page_ova-elems') { |
| 71 |
return; |
| 72 |
} |
| 73 |
|
| 74 |
wp_enqueue_style('ova-elems-font-awesome', plugin_dir_url(__FILE__) . 'assets/css/font.all.min.css', array(), OVA_ELEMS_VER); |
| 75 |
wp_enqueue_script('jquery'); |
| 76 |
} |
| 77 |
add_action('admin_enqueue_scripts', 'ova_elems_admin_enqueue_scripts'); |
| 78 |
|
| 79 |
// Register activation hook |
| 80 |
register_activation_hook(__FILE__, 'ova_elems_activate'); |
| 81 |
|
| 82 |
function ova_elems_activate() { |
| 83 |
// Activation code here |
| 84 |
ova_elems_post_type(); |
| 85 |
flush_rewrite_rules(); |
| 86 |
} |
| 87 |
|
| 88 |
// Register deactivation hook |
| 89 |
register_deactivation_hook(__FILE__, 'ova_elems_deactivate'); |
| 90 |
|
| 91 |
function ova_elems_deactivate() { |
| 92 |
// Deactivation code here |
| 93 |
flush_rewrite_rules(); |
| 94 |
} |
| 95 |
|
| 96 |
function ova_elems_get_posts_for_slider() { |
| 97 |
$args = array( |
| 98 |
'post_type' => 'post', |
| 99 |
'posts_per_page' => -1, |
| 100 |
); |
| 101 |
$posts = get_posts($args); |
| 102 |
$options = ''; |
| 103 |
foreach ($posts as $post) { |
| 104 |
$options .= '<option value="' . esc_attr($post->ID) . '">' . esc_html($post->post_title) . '</option>'; |
| 105 |
} |
| 106 |
echo wp_kses_post($options); |
| 107 |
wp_die(); |
| 108 |
} |
| 109 |
add_action('wp_ajax_ova_elems_get_posts_for_slider', 'ova_elems_get_posts_for_slider'); |
| 110 |
add_action('wp_ajax_nopriv_ova_elems_get_posts_for_slider', 'ova_elems_get_posts_for_slider'); |
| 111 |
|