diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b972665 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +composer.json \ No newline at end of file diff --git a/README.md b/README.md index 1823e45..0a438a8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -wp-plugin-owlcarousel -===================== +# Owl Carousel + A plugin to use Owl Carousel in Wordpress + + +#### Contributers + +- [Jehan Pierre](https://github.com/pjehan) (Original author) +- [Rasmus Taarnby](https://github.com/rasmustaarnby) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..777b141 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "pjehan/wp-plugin-owlcarousel", + "description": "A plugin to use Owl Carousel in Wordpress.", + "type": "wordpress-plugin", + "keywords": ["wordpress", "plugin"], + "homepage": "https://github.com/pjehan/wp-plugin-owlcarousel", + "authors": [ + { + "name": "Jehan Pierre", + "email": "pierre.jehan@gmail.com", + "homepage": "http://www.pierre-jehan.com" + }, + { + "name": "Rasmus Taarnby", + "email": "rt@peytz.dk", + "homepage": "http://peytz.dk/medarbejdere/rt" + } + ] +} diff --git a/owlcarousel.php b/owlcarousel.php index accbaca..2337fe8 100644 --- a/owlcarousel.php +++ b/owlcarousel.php @@ -8,356 +8,374 @@ Licence: GPL2 */ -add_theme_support('post-thumbnails'); - -add_action('init', 'owlcarousel_init'); -add_action('wp_print_scripts', 'owl_register_scripts'); -add_action('wp_print_styles', 'owl_register_styles'); -add_action('widgets_init', 'owl_widgets_init'); -add_action('manage_edit-owl-carousel_columns', 'owl_columnfilter'); -add_action('manage_posts_custom_column', 'owl_column'); -add_action('admin_menu', 'owl_carousel_menu'); -add_action('admin_enqueue_scripts', 'owl_carousel_admin_register_scripts'); - -if(filter_var(get_option('owl_carousel_wordpress_gallery', false), FILTER_VALIDATE_BOOLEAN)) { - add_filter('post_gallery', 'owl_carousel_post_gallery', 10, 2); +add_theme_support( 'post-thumbnails' ); + +add_action( 'init', 'owlcarousel_init' ); +add_action( 'wp_print_scripts', 'owl_register_scripts' ); +add_action( 'wp_print_styles', 'owl_register_styles' ); +add_action( 'widgets_init', 'owl_widgets_init' ); +add_action( 'manage_edit-owl-carousel_columns', 'owl_columnfilter' ); +add_action( 'manage_posts_custom_column', 'owl_column' ); +add_action( 'admin_menu', 'owl_carousel_menu' ); +add_action( 'admin_enqueue_scripts', 'owl_carousel_admin_register_scripts' ); + +if ( filter_var( get_option( 'owl_carousel_wordpress_gallery', false ), FILTER_VALIDATE_BOOLEAN ) ) { + add_filter( 'post_gallery', 'owl_carousel_post_gallery', 10, 2 ); } // Add functions to create a new attachments fields -add_filter("attachment_fields_to_edit", "owl_carousel_attachment_fields_to_edit", null, 2); -add_filter("attachment_fields_to_save", "owl_carousel_attachment_fields_to_save", null, 2); +add_filter( "attachment_fields_to_edit", "owl_carousel_attachment_fields_to_edit", null, 2 ); +add_filter( "attachment_fields_to_save", "owl_carousel_attachment_fields_to_save", null, 2 ); /** * Initilize the plugin */ function owlcarousel_init() { - $labels = array( - 'name' => __('Owl Carousel', 'owl-carousel-domain'), - 'singular_name' => __('Carousel Item', 'owl-carousel-domain'), - 'add_new' => __('Add New Item', 'owl-carousel-domain'), - 'add_new_item' => __('Add New Carousel Item', 'owl-carousel-domain'), - 'edit_item' => __('Edit Carousel Item', 'owl-carousel-domain'), - 'new_item' => __('Add New Carousel Item', 'owl-carousel-domain'), - 'view_item' => __('View Item', 'owl-carousel-domain'), - 'search_items' => __('Search Carousel', 'owl-carousel-domain'), - 'not_found' => __('No carousel items found', 'owl-carousel-domain'), - 'not_found_in_trash' => __('No carousel items found in trash', 'owl-carousel-domain'), - ); - - register_post_type('owl-carousel', array( - 'public' => true, - 'publicly_queryable' => false, - 'exclude_from_search' => true, - 'label' => 'Owl Carousel', - 'menu_icon' => plugins_url('/owl-carousel/images/owl-logo-16.png'), - 'labels' => $labels, - 'capability_type' => 'post', - 'supports' => array( - 'title', - 'editor', - 'thumbnail' - ) - )); - - register_taxonomy( + $labels = array( + 'name' => __( 'Owl Carousel', 'owl-carousel-domain' ), + 'singular_name' => __( 'Carousel Item', 'owl-carousel-domain' ), + 'add_new' => __( 'Add New Item', 'owl-carousel-domain' ), + 'add_new_item' => __( 'Add New Carousel Item', 'owl-carousel-domain' ), + 'edit_item' => __( 'Edit Carousel Item', 'owl-carousel-domain' ), + 'new_item' => __( 'Add New Carousel Item', 'owl-carousel-domain' ), + 'view_item' => __( 'View Item', 'owl-carousel-domain' ), + 'search_items' => __( 'Search Carousel', 'owl-carousel-domain' ), + 'not_found' => __( 'No carousel items found', 'owl-carousel-domain' ), + 'not_found_in_trash' => __( 'No carousel items found in trash', 'owl-carousel-domain' ), + ); + + register_post_type( 'owl-carousel', array( + 'public' => true, + 'publicly_queryable' => false, + 'exclude_from_search' => true, + 'label' => 'Owl Carousel', + 'menu_icon' => plugins_url( '/owl-carousel/images/owl-logo-16.png' ), + 'labels' => $labels, + 'capability_type' => 'post', + 'supports' => array( + 'title', + 'editor', + 'thumbnail' + ) + ) ); + + register_taxonomy( 'Carousel', 'owl-carousel', array( 'label' => __( 'Carousel' ), 'rewrite' => array( 'slug' => 'carousel' ), 'hierarchical' => true, - 'show_admin_column' => true, + 'show_admin_column' => true, ) ); - add_image_size('owl_widget', 180, 100, true); - add_image_size('owl_function', 600, 280, true); + add_image_size( 'owl_widget', 180, 100, true ); + add_image_size( 'owl_function', 600, 280, true ); - add_shortcode('owl-carousel', 'owl_function'); - add_filter("mce_external_plugins", "owl_register_tinymce_plugin"); - add_filter('mce_buttons', 'owl_add_tinymce_button'); + add_shortcode( 'owl-carousel', 'owl_function' ); + add_filter( "mce_external_plugins", "owl_register_tinymce_plugin" ); + add_filter( 'mce_buttons', 'owl_add_tinymce_button' ); - // Add Wordpress Gallery option - add_option('owl_carousel_wordpress_gallery', 'off'); - add_option('owl_carousel_orderby', 'post_date'); + // Add Wordpress Gallery option + add_option( 'owl_carousel_wordpress_gallery', 'off' ); + add_option( 'owl_carousel_orderby', 'post_date' ); } + function owl_carousel_menu() { - add_submenu_page('edit.php?post_type=owl-carousel', __('Parameters', 'owl-carousel-domain'), __('Parameters', 'owl-carousel-domain'), 'manage_options', 'owl-carousel-parameters', 'submenu_parameters'); + add_submenu_page( 'edit.php?post_type=owl-carousel', __( 'Parameters', 'owl-carousel-domain' ), __( 'Parameters', 'owl-carousel-domain' ), 'manage_options', 'owl-carousel-parameters', 'submenu_parameters' ); } + function submenu_parameters() { - $isWordpressGallery = (filter_var(get_option('owl_carousel_wordpress_gallery', false), FILTER_VALIDATE_BOOLEAN)) ? 'checked' : ''; - $orderBy = get_option('owl_carousel_orderby', 'post_date'); - $orderByOptions = array('post_date', 'title'); + $isWordpressGallery = ( filter_var( get_option( 'owl_carousel_wordpress_gallery', false ), FILTER_VALIDATE_BOOLEAN ) ) ? 'checked' : ''; + $orderBy = get_option( 'owl_carousel_orderby', 'post_date' ); + $orderByOptions = array( 'post_date', 'title' ); - echo '