Category Archives: Plugins

Create Plugin From Custom Post Type

1. Create folder with name “rar-portfolio” in plugins folder.
2. Create a file name with “portfolio.php”.
3. Add below code into “portfolio.php”.

Note: Create custom post type on plugin activation with short code

We used this custom post type : Create and display custom post type with Texonomy, Metabox and Tag


<?php
/**
 * Plugin Name: RAR Portfolio
 * Plugin URI: http://rarthemes.com
 * Description: Create custom post type on plugin activation with short code
 * Version: 1.0.0
 * Author: Ravi Radadiya
 * Author URI: http://rarthemes.com
 * License: GPL2
 */
 
/***** Start custom post type - Portfolios *****/
function portfolios_custom_init() {
$labels = array(
'name' => __('Portfolios','themename'),
'singular_name' => __('portfolios','themename'),
'add_new' => __('Add New','themename'),
'add_new_item' => __('Add New Portfolio','themename'),
'edit_item' => __('Edit Portfolio','themename'),
'new_item' => __('New Portfolio','themename'),
'all_items' => __('All Portfolios','themename'),
'view_item' => __('View Portfolios','themename'),
'search_items' => __('Search Portfolio','themename'),
'not_found' => __('No Portfolios found','themename'),
'not_found_in_trash' => __('No Portfolios found in Trash','themename'),
'parent_item_colon' => '',
'menu_name' => __('Portfolios','themename')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'portfolios' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor','thumbnail')
 
);
register_post_type( 'portfolios', $args );
register_taxonomy("portfolio-categories",
array("portfolios"),
array("hierarchical" => true,
'show_admin_column'   => true,
"label" => "Portfolio Categories",
"singular_label" => "Portfolio Categories",
"rewrite" => array( 'slug' => 'portfolio_category' ,
 
)));
 
register_taxonomy("portfolio-tag",
array("portfolios"),
array("hierarchical" => false,
'show_admin_column'   => true,
"label" => "Portfolio Tag",
"singular_label" => "Portfolio tag",
"rewrite" => array( 'slug' => 'portfolio_tag' ,
 
)));
 
}
add_action( 'init', 'portfolios_custom_init' );
 
/*****  Custom Meta Box - portfolios *****/
 
add_action( 'add_meta_boxes', 'meta_box_portfolio' );
function meta_box_portfolio()
{
add_meta_box( 'meta_box_portfolio_id', 'Enter Portfolio info', 'portfolio_website_info', 'portfolios', 'normal', 'high' );
}
function portfolio_website_info( $post )
{
$values = get_post_custom( $post->ID );
$portfolio_url = isset( $values['portfolio_url'] ) ? esc_attr( $values['portfolio_url'][0] ) : '';
$portfolio_text = isset( $values['portfolio_text'] ) ? esc_attr( $values['portfolio_text'][0] ) : '';
$portfolio_image = isset( $values['portfolio_image'] ) ? esc_attr( $values['portfolio_image'][0] ) : '';
 
wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
?>

<p>Portfolio URL</p>
<input type="text" name="portfolio_url" value="<?php echo esc_url( $portfolio_url ); ?>" class="widefat" placeholder="Portfolio Url" />
<p>Portfolio Text</p>
<input type="text" name="portfolio_text" value="<?php echo esc_attr( $portfolio_text ); ?>" class="widefat" placeholder="Portfolio Text" />
<p>Portfolio Image</p>
<input id=""  type="text" class=" mytheme_media_url upload" name="portfolio_image" value="<?php echo esc_attr( $portfolio_image ); ?>" placeholder="No file chosen"  />
<?php if(!empty($instance['image'])) { ?>
<img src="<?php echo $instance['image']; ?>"  />
<?php } ?>
<input id="mytheme_image_uploader"  class="button mytheme_media_upload" type="button" value="Upload" />
<?php
} 
add_action( 'save_post', 'portfolio_meta_box_save' );
function portfolio_meta_box_save( $post_id )
{
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
if( isset( $_POST['portfolio_url'] ) ) update_post_meta( $post_id, 'portfolio_url', esc_url( $_POST['portfolio_url'] ) );
if( isset( $_POST['portfolio_text'] ) ) update_post_meta( $post_id, 'portfolio_text', esc_attr( $_POST['portfolio_text'] ) );
if( isset( $_POST['portfolio_image'] ) ) update_post_meta( $post_id, 'portfolio_image', esc_attr( $_POST['portfolio_image'] ) );
}
/*** end portfolio post type ***/

/* Register activation hook */
function portfolio_plugin_activation() {
    portfolios_custom_init();
   // flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'portfolio_plugin_activation' );

/* Display posts */

function display_portfolio(){
	?>
<div class="row">
  <?php
$legal_portfolio_args = array(
'paged' => $paged,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'portfolios',
'post_status' => 'publish'
);
$legal_portfolio = new WP_Query( $legal_portfolio_args );
while ( $legal_portfolio->have_posts() ) { $legal_portfolio->the_post();
?>
  <div class="col-md-6 col-sm-6 attorneys">
    <div class="our-section-box">
      <?php if ( has_post_thumbnail() ) { ?>
      <a href="<?php the_permalink(); ?>" target="_blank">
      <div class="col-md-12 no-padding our-box-left">
        <?php the_post_thumbnail( 'legal-ourteam-thumbnail-image', array( 'alt' => get_the_title(), 'class' => 'img-responsive') ); ?>
      </div>
      </a>
      <?php } ?>
      <div class="col-md-12 our-box-right">
        <h4>
          <?php the_title(); ?>
        </h4>
        <?php the_content(); ?>
        <?php
echo 'URL: '.  get_post_meta( get_the_ID(), 'portfolio_url', true );
echo '<br>text: '. get_post_meta( get_the_ID(), 'portfolio_text', true );
echo '<br>Image: '. get_post_meta( get_the_ID(), 'portfolio_image', true );
echo '<br>Category: '; foreach((get_the_terms($post->ID, 'portfolio-categories')) as $term) { echo $term->name. ' ,'  ; }
echo '<br>tag: '; foreach((get_the_terms($post->ID, 'portfolio-tag')) as $term) { echo $term->name. ' ,'  ; }
?>
      </div>
    </div>
  </div>
  <?php } ?>
</div>
<?php
}

/* Add short code */

add_shortcode('rar_portfolio', 'portfolio_shortcode');
function portfolio_shortcode(){ 
	return display_portfolio();
}

Advertisements

Approve Posts, Added by Public Users in WordPress

1. All Users can add post from fronted.
2. After submitting post will display on admin posts list as pending mode.
3. Post will display on fronted after publishing post by admin.

https://wordpress.org/plugins/user-submitted-posts/screenshots/

Plugin- One page scroll

Plugin name
https://wordpress.org/plugins/page-scroll-to-id/

multiple featured images – plugin

Use this plugin for multiple featured images

https://wordpress.org/plugins/dynamic-featured-image/

Display multiple images.

<div id="owl-demo" class="owl-carousel owl-theme">
  <?php
		if( class_exists('Dynamic_Featured_Image') ) {
			 global $dynamic_featured_image;
			 $featured_images = $dynamic_featured_image->get_featured_images( get_the_ID() );
		
			 foreach( $featured_images as $image ) {
					echo "<img src='{$image['full']}'/>";  
				  }
			 if(empty($featured_images)){
					the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'class' => 'img-responsive') );
				 }	  
		}
?>
</div>

If you want to add slider just add loop in slider structure (You can uuse corosal slider).

Plugin for membership plan with diffrent payment gatway

http://www.paidmembershipspro.com/

https://wordpress.org/plugins/paid-memberships-pro/

For displaying all plans:

[pmpro_levels]

Display Perticular level for signup:

install this plugins adons=>
https://wordpress.org/plugins/pmpro-register-helper/

[pmpro_signup level=”6″ short=”1″ intro=”6″ button=”Signup Now”]

conditional widget

Widget Logic lets you control on which pages widgets appear using WP’s conditional tags. It also adds a ‘widget_content’ filter.

https://wordpress.org/plugins/widget-logic/
Widget Logic

Plugin for shortcode generate in editor

=>Manage From Settings
=>Drage and Drop to delete shortcode.
=>Icon is avalable in all post and page editor.

https://wordpress.org/plugins/shortcoder/

%d bloggers like this: