Custom shortcode – random.php

<?php /** * Parses the passed attributes. */ $attributes = (array) cptui_shortcode_atts( $attributes ); $custom_query = new WP_Query( cptui_filter_query( $attributes ) ); ?> <div class="cptui-shortcode-random cptui-random-<?php echo esc_attr( $attributes[‘cptui_shortcode_id’] ); ?>"> <?php if ( $attributes[‘title’] ) { ?> <h2><?php echo esc_html( $attributes[‘title’] ); ?></h2> <?php } ?> <?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>Read More

Custom shortcode – filter_query

public function filter_query( $args = array(), $attributes = array() ) { if ( ‘random’ !== $attributes[‘cptui_shortcode’] ) { return $args; } $args = array( ‘post_type’ => $attributes[‘post_type’], ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘1’, ‘orderby’ => ‘rand’, ); return $args; }

Custom Shortcode – random method

public function random() { $options = array(); $types = cptuiext_get_post_type_slugs(); foreach ( $types as $type ) { $options[ $type ] = $type; } $shortcode = array( ‘id’ => ‘random’, ‘name’ => __( ‘Random Post’, ‘cptui-extended-random’ ), ‘template’ => ‘random’, ‘template_location’ => $this->path . ‘templates/’, ‘style’ => ‘cptui_default_css’, ‘post_type’ => ‘all’, ‘description’ => __( ‘Display aRead More

Basic Uninstall.php file.

<?php // die when the file is called directly if (!defined(‘WP_UNINSTALL_PLUGIN’)) { die; } //define a vairbale and store an option name as the value. $option_name = ‘plugininze_example_option’; //call delete option and use the vairable inside the quotations delete_option($option_name); // for site options in Multisite delete_site_option($option_name); ?>

Tax Archives – Backfill

/** * Run queries for posts and assign our term to them. * * Conditionally able to run on just one-to-many post types, or all. * * @since 1.0.0 * * @param mixed $chosen Individual post type to potentially use. */ function pluginize_backfill_posts_by_post_type( $chosen = ” ) { // We only want to run thisRead More

Tax Archives – Pre Get Posts

/** * Add our post types to the query. * * @since 1.0.0 * * @param object $query WP_Query instance. */ function pluginize_amend_term_archive( $query ) { if ( is_admin() || ! $query->is_main_query() ) { return; } if ( ! $query->is_category() ) { return; } $query->set( ‘post_type’, array_merge( array( ‘post’ ), cptui_get_post_type_slugs() ) ); } add_action(Read More

Tax Archives – Listener

/** * Add publish hooks to all our CPTUI post types. * * @since 1.0.0 */ function pluginize_post_type_listener() { $post_types = cptui_get_post_type_slugs(); // We default to just our CPTUI post types. foreach ( $post_types as $type ) { add_action( "publish_{$type}", ‘pluginize_auto_add_taxonomy_terms_on_publish’ ); } } add_action( ‘init’, ‘pluginize_post_type_listener’ );

Tax Archives – Set Term

/** * Automatically add our taxonomy term upon publish. * * Term needs to already be created in the database. * * @since 1.0.0 * * @param int $post_id Published post ID. */ function pluginize_auto_add_taxonomy_terms_on_publish( $post_id = 0 ) { if ( ! wp_is_post_revision( $post_id ) ) { $terms = array( 25 ); // SetRead More

edd add images

function cptuiext_edd_axtra_images( $attributes ) { $images = array(); $download_images = get_post_meta( get_the_ID(), ‘edd_download_images’, true ); $images = $download_images; if ( $download_images ) { foreach ( $download_images as $download_image ) { $html = ‘<img class="edd-di-image" src="’ . $download_image[‘image’] . ‘" />’; echo apply_filters( ‘cptui_ext_edd_di_display_images’, $html, $download_image ); } } } add_action( ‘template_edd_after_checkout’, ‘cptuiext_edd_axtra_images’ );

woo rating hook

function cptui_add_woo_rating_below_image( $attributes ) { global $product; if ( isset( $product ) ) { if ( get_option( ‘woocommerce_enable_review_rating’ ) === ‘no’ ) { return; } $rating_count = $product->get_rating_count(); $review_count = $product->get_review_count(); $average = $product->get_average_rating(); if ( $rating_count > 0 ) { ?> <div class="woocommerce-product-rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> <div class="star-rating" title="<?php printf( __( ‘Rated %s outRead More