Skip to content

Instantly share code, notes, and snippets.

@pommiegranit
Last active August 29, 2015 13:56
Show Gist options
  • Save pommiegranit/9288220 to your computer and use it in GitHub Desktop.
Save pommiegranit/9288220 to your computer and use it in GitHub Desktop.
Updates to Scheduled Content Actions plugin to add two new actions
<?php
/**
* Feature Name: Action Feature (handles feature and unfeature)
* Author: Chris Knowles
* Author URI: http://premium.wpmudev.org
* Licence: GPLv3
*/
add_action( 'sca_do_feature_content', 'sca_feature_content' );
// add the tag 'feature' to the post
function sca_feature_content( $post_id ) {
wp_set_object_terms ( $post_id , 'feature' , 'post_tag' );
}
add_action( 'sca_do_unfeature_content', 'sca_unfeature_content' );
// remove the tag 'feature' to the post
function sca_unfeature_content( $post_id ) {
wp_remove_object_terms ( $post_id , 'feature' , 'post_tag' );
}
<?php
/**
* Feature Name: Action Restrict (handles restrict and unrestrict)
* Author: Chris Knowles
* Author URI: http://premium.wpmudev.org
* Licence: GPLv3
*/
add_action( 'sca_do_restrict_content', 'sca_restrict_content' );
// add the post meta fields for Restrict Content plugin
function sca_restrict_content( $post_id ) {
add_post_meta ( $post_id , 'rcUserLevel' , 'Subscriber' );
add_post_meta ( $post_id , 'rcFeedHide' , 'on' );
}
add_action( 'sca_do_unrestrict_content', 'sca_unrestrict_content' );
// remove post meta for Restrict Content plugin
function sca_unrestrict_content( $post_id ) {
delete_post_meta ( $post_id , 'rcUserLevel' , 'Subscriber' );
delete_post_meta ( $post_id , 'rcFeedHide' , 'on' );
}
<?php
/**
* Feature Name: Actions
* Author: HerrLlama for Inpsyde GmbH
* Author URI: http://inpsyde.com
* Licence: GPLv3
*/
function sca_get_actions() {
return apply_filters( 'sca_get_actions' , array(
'stick_content' => __( 'Stick Content', SCA_TEXTDOMAIN ),
'unstick_content' => __( 'Unstick Content', SCA_TEXTDOMAIN ),
'draft_content' => __( 'Draft Content', SCA_TEXTDOMAIN ),
'trash_content' => __( 'Trash Content', SCA_TEXTDOMAIN ),
'delete_content' => __( 'Delete Content', SCA_TEXTDOMAIN ),
'open_comments' => __( 'Open Comments', SCA_TEXTDOMAIN ),
'close_comments' => __( 'Close Comments', SCA_TEXTDOMAIN ),
'feature_content' => __( 'Feature Content', SCA_TEXTDOMAIN ),
'unfeature_content' => __( 'Unfeature Content', SCA_TEXTDOMAIN ),
'restrict_content' => __( 'Restrict Content', SCA_TEXTDOMAIN ),
'unrestrict_content' => __( 'Unrestrict Content', SCA_TEXTDOMAIN ),
) );
}
<?php
/**
* Plugin Name: Scheduled Content Actions
* Description: This plugin provides several actions which affects the behaviour of a post entry. It also handles custom post types and products for woocommerce/jjigoshop.
* Version: 1.0.2
* Author: HerrLlama for Inpsyde GmbH
* Author URI: http://inpsyde.com
* Licence: GPLv3
*/
// check wp
if ( ! function_exists( 'add_action' ) )
return;
// constants
define( 'SCA_TEXTDOMAIN', 'scheduled-content-actions-td' );
// kickoff
add_action( 'plugins_loaded', 'sca_init' );
function sca_init() {
// language
require_once dirname( __FILE__ ) . '/inc/localization.php';
// register all actions, needed in the scheduler
require_once dirname( __FILE__ ) . '/inc/actions.php';
// standard actions
require_once dirname( __FILE__ ) . '/inc/add-action.php';
require_once dirname( __FILE__ ) . '/inc/delete-action.php';
// content actions
require_once dirname( __FILE__ ) . '/inc/action-draft.php';
require_once dirname( __FILE__ ) . '/inc/action-stick.php';
require_once dirname( __FILE__ ) . '/inc/action-unstick.php';
require_once dirname( __FILE__ ) . '/inc/action-trash.php';
require_once dirname( __FILE__ ) . '/inc/action-delete.php';
require_once dirname( __FILE__ ) . '/inc/action-open-comments.php';
require_once dirname( __FILE__ ) . '/inc/action-close-comments.php';
require_once dirname( __FILE__ ) . '/inc/action-feature.php';
require_once dirname( __FILE__ ) . '/inc/action-restrict.php';
// scheduler
require_once dirname( __FILE__ ) . '/inc/scheduler.php';
// everything below is just in the admin panel
if ( ! is_admin() )
return;
// scripts and styles
require_once dirname( __FILE__ ) . '/inc/scripts.php';
require_once dirname( __FILE__ ) . '/inc/styles.php';
// ajax actions
require_once dirname( __FILE__ ) . '/inc/ajax-add-action.php';
require_once dirname( __FILE__ ) . '/inc/ajax-delete-action.php';
// meta box
require_once dirname( __FILE__ ) . '/inc/meta-box.php';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment