Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: Tegyjot Runners
- */
- if ( !function_exists( 'add_action' ) ) {
- echo "Nana! Csak egy plugin vagyok, ne nyiss meg direktben!";
- exit;
- }
- function register_runners_posttype() {
- /**
- * Post Type: Runners.
- */
- $labels = array(
- "name" => __( "Runners", "" ),
- "singular_name" => __( "runners", "" ),
- );
- $args = array(
- "label" => __( "Runners", "" ),
- "labels" => $labels,
- "description" => "",
- "public" => true,
- "publicly_queryable" => true,
- "show_ui" => true,
- "show_in_rest" => false,
- "rest_base" => "",
- "has_archive" => false,
- "show_in_menu" => true,
- "exclude_from_search" => false,
- "capability_type" => "post",
- "map_meta_cap" => true,
- "hierarchical" => true,
- "rewrite" => array( "slug" => "runners", "with_front" => true ),
- "menu_icon" => "dashicons-groups",
- "query_var" => true,
- "supports" => array( "title", "editor" ),
- "taxonomies" => array( "runners" ),
- );
- register_post_type( "runners", $args );
- }
- add_action( 'init', 'register_runners_posttype' );
- function cptui_register_my_taxes_runners() {
- /**
- * Taxonomy: Runners.
- */
- $labels = array(
- "name" => __( "Runners", "custom-post-type-ui" ),
- "singular_name" => __( "Runner", "custom-post-type-ui" ),
- );
- $args = array(
- "label" => __( "Runners", "custom-post-type-ui" ),
- "labels" => $labels,
- "public" => true,
- "publicly_queryable" => true,
- "hierarchical" => false,
- "show_ui" => true,
- "show_in_menu" => true,
- "show_in_nav_menus" => true,
- "query_var" => true,
- "rewrite" => array( 'slug' => 'runners', 'with_front' => true, ),
- "show_admin_column" => false,
- "show_in_rest" => true,
- "rest_base" => "runners",
- "rest_controller_class" => "WP_REST_Terms_Controller",
- "show_in_quick_edit" => false,
- );
- register_taxonomy( "runners", array( "runners" ), $args );
- }
- add_action( 'init', 'cptui_register_my_taxes_runners' );
- function ed_charitable_register_futok_field() {
- /**
- * Set up the options that people can choose from in the select field.
- */
- $terms = get_terms( array(
- 'taxonomy' => 'runners',
- 'hide_empty' => false,
- ) );
- $futok[] = pll__('Any');
- foreach($terms as $term){
- $futok[] = $term->name;
- //$futok[$term->slug]=$term->name;
- }
- $futok[] = pll__('Group (21 km above running)');
- /**
- * Define a new select field.
- */
- $field = new Charitable_Donation_Field( 'futok_field', array(
- 'label' => pll__( 'Choose a runner', 'charitable' ),
- 'data_type' => 'user',
- 'donation_form' => array(
- 'type' => 'select',
- 'show_after' => 'email',
- 'required' => true,
- 'options' => $futok,
- ),
- 'admin_form' => true,
- 'show_in_meta' => true,
- 'show_in_export' => true,
- 'email_tag' => array(
- 'description' => pll__( 'The runner' ),
- ),
- ) );
- /**
- * Register the select field.
- */
- charitable()->donation_fields()->register_field( $field );
- }
- add_action( 'init', 'ed_charitable_register_futok_field' );
- function ed_add_campaign_stats_to_receipt( $donation ) {
- $campaigns = $donation->get_campaign_donations();
- ob_start();
- printf( '<h4>%s</h4>', pll__( 'Campaign Stats' ) );
- foreach ( $campaigns as $campaign_donation ) {
- $campaign = charitable_get_campaign( $campaign_donation->campaign_id );
- printf( '<p><strong>%s</strong></p>', $campaign_donation->campaign_name );
- charitable_template_campaign_donation_summary( $campaign );
- }
- echo ob_get_clean();
- }
- add_action( 'charitable_donation_receipt_after', 'ed_add_campaign_stats_to_receipt' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment