query("DROP TABLE IF EXISTS {$wpdb->prefix}easy-flexible-testimonials"); } register_uninstall_hook(__FILE__, 'eft_deleteTable'); //Drop Table on plugin delete /* * ************************** Create a new admin menu ******************************** */ add_action('admin_menu', 'eft_register_my_custom_menu_page'); function eft_register_my_custom_menu_page() { add_menu_page('Easy Flexible Testimonials', 'Easy Flexible Testimonials', 'manage_options', 'easy-flexible-testimonials/testimonial.php', '', plugins_url('easy-flexible-testimonials/images/icon.png'), 6); } /* * ************************** Create a new admin menu ******************************** */ /* Adding Custom CSS */ function eft_add_css() { wp_enqueue_style('styleflex', plugins_url('/css/styleflex.css', __FILE__), false, '1.0.0', 'all'); } add_action('admin_enqueue_scripts', "eft_add_css"); /* Creating the testimonial table */ function eft_create_table() { global $wpdb; $table_name = $wpdb->prefix . 'easy_flexible_testimonials'; //table is not created. you may create the table here. $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `testimonial_title` VARCHAR( 500 ) NOT NULL , `testimonial_description` TEXT NOT NULL , `author_image` VARCHAR( 200 ) NOT NULL , `author_name` VARCHAR( 200 ) NOT NULL , `author_address` TEXT NOT NULL , `created` DATE NOT NULL , `is_active` TINYINT( 4 ) NOT NULL COMMENT '0=>inactive, 1=>active' ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($sql); } register_activation_hook(__FILE__, 'eft_create_table'); /* Table Creation Ends Here */ add_shortcode("list-testimonials", "eft_displaytest_handler"); function eft_displaytest_handler($limit = NULL) { $atts = shortcode_atts($limit, NULL); $limit = $atts['limit']; //run function that actually does the work of the plugin $demolph_output = eft_displayTestimonials($limit); //send back text to replace shortcode in post return $demolph_output; } add_action('admin_print_scripts', 'add_editor' ); add_action('admin_print_styles', 'editor_css' ); function editor_css() { wp_enqueue_style('thickbox'); } function add_editor() { wp_enqueue_script('editor'); wp_enqueue_script('thickbox'); add_action( 'admin_head', 'wp_tiny_mce' ); } // Display the testimonials in the front end function eft_displayTestimonials($limit = NULL) { $globalimagepath = wp_upload_dir(); global $wpdb; $table_name = $wpdb->prefix . 'easy_flexible_testimonials'; $displayFrontEnd = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name ORDER BY id DESC LIMIT %d", $limit)); foreach ($displayFrontEnd as $frontdetails) { echo $demolp_output = "
author_image . "' height='100' width='100'>

$frontdetails->testimonial_title

$frontdetails->testimonial_description

$frontdetails->author_name

"; } } ?>