t push -u origin master

parents
Pipeline #15 skipped
This diff is collapsed.
<?php
/*
* Plugin Name: autoshortcoder
* Version: 1.0
* Plugin URI: http://www.hughlashbrooke.com/
* Description: This is your starter template for your next WordPress plugin.
* Author: Hugh Lashbrooke
* Author URI: http://www.hughlashbrooke.com/
* Requires at least: 4.0
* Tested up to: 4.0
*
* Text Domain: autoshortcoder
* Domain Path: /lang/
*
* @package WordPress
* @author Hugh Lashbrooke
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// Load plugin class files
require_once( 'includes/class-autoshortcoder.php' );
require_once( 'includes/class-autoshortcoder-settings.php' );
// Load plugin libraries
require_once( 'includes/lib/class-autoshortcoder-admin-api.php' );
require_once( 'includes/lib/class-autoshortcoder-post-type.php' );
require_once( 'includes/lib/class-autoshortcoder-taxonomy.php' );
/**
* Returns the main instance of autoshortcoder to prevent the need to use globals.
*
* @since 1.0.0
* @return object autoshortcoder
*/
function autoshortcoder () {
$instance = autoshortcoder::instance( __FILE__, '1.0.0' );
if ( is_null( $instance->settings ) ) {
$instance->settings = autoshortcoder_Settings::instance( $instance );
}
return $instance;
}
autoshortcoder();
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
class autoshortcoder {
/**
* The single instance of autoshortcoder.
* @var object
* @access private
* @since 1.0.0
*/
private static $_instance = null;
/**
* Settings class object
* @var object
* @access public
* @since 1.0.0
*/
public $settings = null;
/**
* The version number.
* @var string
* @access public
* @since 1.0.0
*/
public $_version;
/**
* The token.
* @var string
* @access public
* @since 1.0.0
*/
public $_token;
/**
* The main plugin file.
* @var string
* @access public
* @since 1.0.0
*/
public $file;
/**
* The main plugin directory.
* @var string
* @access public
* @since 1.0.0
*/
public $dir;
/**
* The plugin assets directory.
* @var string
* @access public
* @since 1.0.0
*/
public $assets_dir;
/**
* The plugin assets URL.
* @var string
* @access public
* @since 1.0.0
*/
public $assets_url;
/**
* Suffix for Javascripts.
* @var string
* @access public
* @since 1.0.0
*/
public $script_suffix;
/**
* Constructor function.
* @access public
* @since 1.0.0
* @return void
*/
public function __construct ( $file = '', $version = '1.0.0' ) {
$this->_version = $version;
$this->_token = 'autoshortcoder';
// Load plugin environment variables
$this->file = $file;
$this->dir = dirname( $this->file );
$this->assets_dir = trailingslashit( $this->dir ) . 'assets';
$this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $this->file ) ) );
$this->script_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
register_activation_hook( $this->file, array( $this, 'install' ) );
// Load frontend JS & CSS
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ), 10 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10 );
// Load admin JS & CSS
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 10, 1 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ), 10, 1 );
// Load API for generic admin functions
if ( is_admin() ) {
$this->admin = new autoshortcoder_Admin_API();
}
// Handle localisation
$this->load_plugin_textdomain();
add_action( 'init', array( $this, 'load_localisation' ), 0 );
} // End __construct ()
/**
* Wrapper function to register a new post type
* @param string $post_type Post type name
* @param string $plural Post type item plural name
* @param string $single Post type item single name
* @param string $description Description of post type
* @return object Post type class object
*/
public function register_post_type ( $post_type = '', $plural = '', $single = '', $description = '', $options = array() ) {
if ( ! $post_type || ! $plural || ! $single ) return;
$post_type = new autoshortcoder_Post_Type( $post_type, $plural, $single, $description, $options );
return $post_type;
}
/**
* Wrapper function to register a new taxonomy
* @param string $taxonomy Taxonomy name
* @param string $plural Taxonomy single name
* @param string $single Taxonomy plural name
* @param array $post_types Post types to which this taxonomy applies
* @return object Taxonomy class object
*/
public function register_taxonomy ( $taxonomy = '', $plural = '', $single = '', $post_types = array(), $taxonomy_args = array() ) {
if ( ! $taxonomy || ! $plural || ! $single ) return;
$taxonomy = new autoshortcoder_Taxonomy( $taxonomy, $plural, $single, $post_types, $taxonomy_args );
return $taxonomy;
}
/**
* Load frontend CSS.
* @access public
* @since 1.0.0
* @return void
*/
public function enqueue_styles () {
wp_register_style( $this->_token . '-frontend', esc_url( $this->assets_url ) . 'css/frontend.css', array(), $this->_version );
wp_enqueue_style( $this->_token . '-frontend' );
} // End enqueue_styles ()
/**
* Load frontend Javascript.
* @access public
* @since 1.0.0
* @return void
*/
public function enqueue_scripts () {
wp_register_script( $this->_token . '-frontend', esc_url( $this->assets_url ) . 'js/frontend' . $this->script_suffix . '.js', array( 'jquery' ), $this->_version );
wp_enqueue_script( $this->_token . '-frontend' );
} // End enqueue_scripts ()
/**
* Load admin CSS.
* @access public
* @since 1.0.0
* @return void
*/
public function admin_enqueue_styles ( $hook = '' ) {
wp_register_style( $this->_token . '-admin', esc_url( $this->assets_url ) . 'css/admin.css', array(), $this->_version );
wp_enqueue_style( $this->_token . '-admin' );
} // End admin_enqueue_styles ()
/**
* Load admin Javascript.
* @access public
* @since 1.0.0
* @return void
*/
public function admin_enqueue_scripts ( $hook = '' ) {
wp_register_script( $this->_token . '-admin', esc_url( $this->assets_url ) . 'js/admin' . $this->script_suffix . '.js', array( 'jquery' ), $this->_version );
wp_enqueue_script( $this->_token . '-admin' );
} // End admin_enqueue_scripts ()
/**
* Load plugin localisation
* @access public
* @since 1.0.0
* @return void
*/
public function load_localisation () {
load_plugin_textdomain( 'autoshortcoder', false, dirname( plugin_basename( $this->file ) ) . '/lang/' );
} // End load_localisation ()
/**
* Load plugin textdomain
* @access public
* @since 1.0.0
* @return void
*/
public function load_plugin_textdomain () {
$domain = 'autoshortcoder';
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
load_plugin_textdomain( $domain, false, dirname( plugin_basename( $this->file ) ) . '/lang/' );
} // End load_plugin_textdomain ()
/**
* Main autoshortcoder Instance
*
* Ensures only one instance of autoshortcoder is loaded or can be loaded.
*
* @since 1.0.0
* @static
* @see autoshortcoder()
* @return Main autoshortcoder instance
*/
public static function instance ( $file = '', $version = '1.0.0' ) {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self( $file, $version );
}
return self::$_instance;
} // End instance ()
/**
* Cloning is forbidden.
*
* @since 1.0.0
*/
public function __clone () {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), $this->_version );
} // End __clone ()
/**
* Unserializing instances of this class is forbidden.
*
* @since 1.0.0
*/
public function __wakeup () {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), $this->_version );
} // End __wakeup ()
/**
* Installation. Runs on activation.
* @access public
* @since 1.0.0
* @return void
*/
public function install () {
$this->_log_version_number();
} // End install ()
/**
* Log the plugin version number.
* @access public
* @since 1.0.0
* @return void
*/
private function _log_version_number () {
update_option( $this->_token . '_version', $this->_version );
} // End _log_version_number ()
}
\ No newline at end of file
This diff is collapsed.
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
class autoshortcoder_Post_Type {
/**
* The name for the custom post type.
* @var string
* @access public
* @since 1.0.0
*/
public $post_type;
/**
* The plural name for the custom post type posts.
* @var string
* @access public
* @since 1.0.0
*/
public $plural;
/**
* The singular name for the custom post type posts.
* @var string
* @access public
* @since 1.0.0
*/
public $single;
/**
* The description of the custom post type.
* @var string
* @access public
* @since 1.0.0
*/
public $description;
/**
* The options of the custom post type.
* @var array
* @access public
* @since 1.0.0
*/
public $options;
public function __construct ( $post_type = '', $plural = '', $single = '', $description = '', $options = array() ) {
if ( ! $post_type || ! $plural || ! $single ) return;
// Post type name and labels
$this->post_type = $post_type;
$this->plural = $plural;
$this->single = $single;
$this->description = $description;
$this->options = $options;
// Regsiter post type
add_action( 'init' , array( $this, 'register_post_type' ) );
// Display custom update messages for posts edits
add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_updated_messages' ), 10, 2 );
}
/**
* Register new post type
* @return void
*/
public function register_post_type () {
$labels = array(
'name' => $this->plural,
'singular_name' => $this->single,
'name_admin_bar' => $this->single,
'add_new' => _x( 'Add New', $this->post_type , 'autoshortcoder' ),
'add_new_item' => sprintf( __( 'Add New %s' , 'autoshortcoder' ), $this->single ),
'edit_item' => sprintf( __( 'Edit %s' , 'autoshortcoder' ), $this->single ),
'new_item' => sprintf( __( 'New %s' , 'autoshortcoder' ), $this->single ),
'all_items' => sprintf( __( 'All %s' , 'autoshortcoder' ), $this->plural ),
'view_item' => sprintf( __( 'View %s' , 'autoshortcoder' ), $this->single ),
'search_items' => sprintf( __( 'Search %s' , 'autoshortcoder' ), $this->plural ),
'not_found' => sprintf( __( 'No %s Found' , 'autoshortcoder' ), $this->plural ),
'not_found_in_trash' => sprintf( __( 'No %s Found In Trash' , 'autoshortcoder' ), $this->plural ),
'parent_item_colon' => sprintf( __( 'Parent %s' ), $this->single ),
'menu_name' => $this->plural,
);
$args = array(
'labels' => apply_filters( $this->post_type . '_labels', $labels ),
'description' => $this->description,
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'comments', 'thumbnail' ),
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-post',
);
$args = array_merge($args, $this->options);
register_post_type( $this->post_type, apply_filters( $this->post_type . '_register_args', $args, $this->post_type ) );
}
/**
* Set up admin messages for post type
* @param array $messages Default message
* @return array Modified messages
*/
public function updated_messages ( $messages = array() ) {
global $post, $post_ID;
$messages[ $this->post_type ] = array(
0 => '',
1 => sprintf( __( '%1$s updated. %2$sView %3$s%4$s.' , 'autoshortcoder' ), $this->single, '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->single, '</a>' ),
2 => __( 'Custom field updated.' , 'autoshortcoder' ),
3 => __( 'Custom field deleted.' , 'autoshortcoder' ),
4 => sprintf( __( '%1$s updated.' , 'autoshortcoder' ), $this->single ),
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.' , 'autoshortcoder' ), $this->single, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __( '%1$s published. %2$sView %3$s%4s.' , 'autoshortcoder' ), $this->single, '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->single, '</a>' ),
7 => sprintf( __( '%1$s saved.' , 'autoshortcoder' ), $this->single ),
8 => sprintf( __( '%1$s submitted. %2$sPreview post%3$s%4$s.' , 'autoshortcoder' ), $this->single, '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->single, '</a>' ),
9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.' , 'autoshortcoder' ), $this->single, '<strong>' . date_i18n( __( 'M j, Y @ G:i' , 'autoshortcoder' ), strtotime( $post->post_date ) ) . '</strong>', '<a target="_blank" href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->single, '</a>' ),
10 => sprintf( __( '%1$s draft updated. %2$sPreview %3$s%4$s.' , 'autoshortcoder' ), $this->single, '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->single, '</a>' ),
);
return $messages;
}
/**
* Set up bulk admin messages for post type
* @param array $bulk_messages Default bulk messages
* @param array $bulk_counts Counts of selected posts in each status
* @return array Modified messages
*/
public function bulk_updated_messages ( $bulk_messages = array(), $bulk_counts = array() ) {
$bulk_messages[ $this->post_type ] = array(
'updated' => sprintf( _n( '%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'autoshortcoder' ), $bulk_counts['updated'], $this->single, $this->plural ),
'locked' => sprintf( _n( '%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'autoshortcoder' ), $bulk_counts['locked'], $this->single, $this->plural ),
'deleted' => sprintf( _n( '%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'autoshortcoder' ), $bulk_counts['deleted'], $this->single, $this->plural ),
'trashed' => sprintf( _n( '%1$s %2$s moved to the Trash.', '%1$s %3$s moved to the Trash.', $bulk_counts['trashed'], 'autoshortcoder' ), $bulk_counts['trashed'], $this->single, $this->plural ),
'untrashed' => sprintf( _n( '%1$s %2$s restored from the Trash.', '%1$s %3$s restored from the Trash.', $bulk_counts['untrashed'], 'autoshortcoder' ), $bulk_counts['untrashed'], $this->single, $this->plural ),
);
return $bulk_messages;
}
}
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
class autoshortcoder_Taxonomy {
/**
* The name for the taxonomy.
* @var string
* @access public
* @since 1.0.0
*/
public $taxonomy;
/**
* The plural name for the taxonomy terms.
* @var string
* @access public
* @since 1.0.0
*/
public $plural;
/**
* The singular name for the taxonomy terms.
* @var string
* @access public
* @since 1.0.0
*/
public $single;
/**
* The array of post types to which this taxonomy applies.
* @var array
* @access public
* @since 1.0.0
*/
public $post_types;
/**
* The array of taxonomy arguments
* @var array
* @access public
* @since 1.0.0
*/
public $taxonomy_args;
public function __construct ( $taxonomy = '', $plural = '', $single = '', $post_types = array(), $tax_args = array() ) {
if ( ! $taxonomy || ! $plural || ! $single ) return;
// Post type name and labels
$this->taxonomy = $taxonomy;
$this->plural = $plural;
$this->single = $single;
if ( ! is_array( $post_types ) ) {
$post_types = array( $post_types );
}
$this->post_types = $post_types;
$this->taxonomy_args = $tax_args;
// Register taxonomy
add_action('init', array( $this, 'register_taxonomy' ) );
}
/**
* Register new taxonomy
* @return void
*/
public function register_taxonomy () {
$labels = array(
'name' => $this->plural,
'singular_name' => $this->single,
'menu_name' => $this->plural,
'all_items' => sprintf( __( 'All %s' , 'autoshortcoder' ), $this->plural ),
'edit_item' => sprintf( __( 'Edit %s' , 'autoshortcoder' ), $this->single ),
'view_item' => sprintf( __( 'View %s' , 'autoshortcoder' ), $this->single ),
'update_item' => sprintf( __( 'Update %s' , 'autoshortcoder' ), $this->single ),
'add_new_item' => sprintf( __( 'Add New %s' , 'autoshortcoder' ), $this->single ),
'new_item_name' => sprintf( __( 'New %s Name' , 'autoshortcoder' ), $this->single ),
'parent_item' => sprintf( __( 'Parent %s' , 'autoshortcoder' ), $this->single ),
'parent_item_colon' => sprintf( __( 'Parent %s:' , 'autoshortcoder' ), $this->single ),
'search_items' => sprintf( __( 'Search %s' , 'autoshortcoder' ), $this->plural ),
'popular_items' => sprintf( __( 'Popular %s' , 'autoshortcoder' ), $this->plural ),
'separate_items_with_commas' => sprintf( __( 'Separate %s with commas' , 'autoshortcoder' ), $this->plural ),
'add_or_remove_items' => sprintf( __( 'Add or remove %s' , 'autoshortcoder' ), $this->plural ),
'choose_from_most_used' => sprintf( __( 'Choose from the most used %s' , 'autoshortcoder' ), $this->plural ),
'not_found' => sprintf( __( 'No %s found' , 'autoshortcoder' ), $this->plural ),
);
$args = array(
'label' => $this->plural,
'labels' => apply_filters( $this->taxonomy . '_labels', $labels ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'meta_box_cb' => null,
'show_admin_column' => true,
'update_count_callback' => '',
'query_var' => $this->taxonomy,
'rewrite' => true,
'sort' => '',
);
$args = array_merge($args, $this->taxonomy_args);
register_taxonomy( $this->taxonomy, $this->post_types, apply_filters( $this->taxonomy . '_register_args', $args, $this->taxonomy, $this->post_types ) );
}
}
<?php
// Silence is golden
\ No newline at end of file
=== autoshortcoder ===
Contributors: nextime
Donate link: http://www.nexlab.net/supportus
Tags: wordpress, plugin, shortcodes
Requires at least: 3.9
Tested up to: 4.5.2
Stable tag: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Programmatically add shortcodes to pages and posts based on tags
== Description ==
Programmatically add any shortcode to pages and posts based on tags after the content.
== Installation ==
Installing "autoshortcoder" can be done either by searching for "autoshortcoder" via the "Plugins > Add New" screen in your WordPress dashboard, or by using the following steps:
1. Download the plugin via WordPress.org
1. Upload the ZIP file through the 'Plugins > Add New > Upload' screen in your WordPress dashboard
1. Activate the plugin through the 'Plugins' menu in WordPress
== Changelog ==
= 1.0 =
* 2016-05-21
* Initial release
<?php
/**
*
* This file runs when the plugin in uninstalled (deleted).
* This will not run when the plugin is deactivated.
* Ideally you will add all your clean-up scripts here
* that will clean-up unused meta, options, etc. in the database.
*
*/
// If plugin is not being uninstalled, exit (do nothing)
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Do something here if plugin is being uninstalled.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment