This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: CPT Templates | |
Plugin URI: http://www.riversportokc.org/ | |
Description: Create Custom Post Type Templates | |
Author: BigWing Interactive | |
Version: 1.0.0 | |
Requires at least: 4.1 | |
Author URI: http://bigwing.com | |
Contributors: ronalfy, bigwing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function init() { | |
add_action( 'add_meta_boxes', array( &$this, 'register_meta_boxes' ) ); | |
$labels = array( | |
'name' => 'Galleries', | |
'singular_name' => 'Gallery', | |
'menu_name' => 'Galleries', | |
'name_admin_bar' => 'Galleries', | |
'add_new' => 'Add New', | |
'add_new_item' => 'Add New Gallery', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function post_type_choose_templates() { | |
global $post; | |
$theme = wp_get_theme(); | |
$post_types_templates_directory = $theme->get_stylesheet_directory() . '/cpt-templates/' . $post->post_type; | |
$files = self::scandir( $post_types_templates_directory, array( 'php' ) ); | |
$current_page_template = get_post_meta( $post->ID, '_wp_page_template', true ); | |
if ( ! $current_page_template ) { | |
$current_page_template = 'none'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function maybe_get_cpt_template( $original_template ) { | |
$object = get_queried_object(); | |
// Check if post type template | |
if ( is_object( $object ) && is_a( $object, 'WP_Post' ) && in_array( $object->post_type, $this->post_types ) ) { | |
$maybe_template = get_post_meta( $object->ID, '_wp_page_template', true ); | |
if ( $maybe_template ) { | |
$template = get_query_template( $object->post_type, $maybe_template ); | |
if ( file_exists( $template ) ) { | |
return $template; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function save_post( $post_id ) { | |
if ( wp_is_post_revision( $post_id ) ) | |
return; | |
if ( isset( $_POST[ 'post_type_page_template' ] ) ) { | |
$template = sanitize_text_field( $_POST[ 'post_type_page_template' ] ); | |
if ( 'none' == $template ) { | |
delete_post_meta( $post_id, '_wp_page_template' ); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) { | |
if ( ! is_dir( $path ) ) | |
return false; | |
if ( $extensions ) { | |
$extensions = (array) $extensions; | |
$_extensions = implode( '|', $extensions ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'gform_after_submission', 'braums_after_submission', 10, 2 ); | |
function braums_after_submission( $entry, $form ) { | |
?> | |
<script> | |
function braums_datalayer_push() { | |
var form_submission = sessionStorage.getItem('entry_<?php echo absint( $entry[ 'id' ] ); ?>'); | |
if ( null == form_submission ) { | |
if ( typeof( dataLayer ) != 'undefined' ) { | |
dataLayer.push({'event': 'BWTrackEvent', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'bp_core_fetch_avatar', 'mpp_bp_avatar', 10, 2 ); | |
function mpp_bp_avatar( $img, $params ) { | |
// Determine if user has an avatar override | |
$avatar_override = get_user_option( 'metronet_avatar_override', $params[ 'item_id' ] ); | |
if ( !$avatar_override || $avatar_override != 'on' ) return $img; | |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $params[ 'item_id' ] ) ); | |
if ( 0 === $profile_post_id || 'mt_pp' !== get_post_type( $profile_post_id ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Multisite for https://wordpress.org/plugins/wp-force-login/ | |
* Allows all users of the network to view all sites and posts on the network | |
* Intended to be used as an mu-plugin | |
*/ | |
add_action( 'template_redirect', function() { | |
if ( is_user_logged_in() ) { | |
remove_action('template_redirect', 'v_forcelogin'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'gform_pagination_event_label', 'ronalfy_gform_pagination_event_label', 10, 4 ); | |
function ronalfy_gform_pagination_event_label( $label, $form, $source_page_number, $current_page_number ) { | |
$event_label = sprintf( '%s::%d::%d', esc_html( $_SERVER['REQUEST_URI'] ), absint( $source_page_number ), absint( $current_page_number ) ); | |
return $event_label; | |
} | |
?> |