gkaroly

Untitled

May 22nd, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.77 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Plugin Name: Tegyjot Runners
  4.  */
  5.  
  6. if ( !function_exists( 'add_action' ) ) {
  7.     echo "Nana! Csak egy plugin vagyok, ne nyiss meg direktben!";
  8.     exit;
  9. }
  10.  
  11.  
  12. function register_runners_posttype() {
  13.  
  14.  
  15.     /**
  16.      * Post Type: Runners.
  17.      */
  18.  
  19.     $labels = array(
  20.     "name" => __( "Runners", "" ),
  21.     "singular_name" => __( "runners", "" ),
  22.     );
  23.  
  24.     $args = array(
  25.     "label" => __( "Runners", "" ),
  26.     "labels" => $labels,
  27.     "description" => "",
  28.     "public" => true,
  29.     "publicly_queryable" => true,
  30.     "show_ui" => true,
  31.     "show_in_rest" => false,
  32.     "rest_base" => "",
  33.     "has_archive" => false,
  34.     "show_in_menu" => true,
  35.     "exclude_from_search" => false,
  36.     "capability_type" => "post",
  37.     "map_meta_cap" => true,
  38.     "hierarchical" => true,
  39.     "rewrite" => array( "slug" => "runners", "with_front" => true ),
  40.     "menu_icon" => "dashicons-groups",
  41.     "query_var" => true,
  42.     "supports" => array( "title", "editor" ),
  43.     "taxonomies" => array( "runners" ),
  44.     );
  45.  
  46.     register_post_type( "runners", $args );
  47.  
  48. }
  49. add_action( 'init', 'register_runners_posttype' );
  50.  
  51. function cptui_register_my_taxes_runners() {
  52.  
  53.     /**
  54.      * Taxonomy: Runners.
  55.      */
  56.  
  57.     $labels = array(
  58.     "name" => __( "Runners", "custom-post-type-ui" ),
  59.     "singular_name" => __( "Runner", "custom-post-type-ui" ),
  60.     );
  61.  
  62.     $args = array(
  63.     "label" => __( "Runners", "custom-post-type-ui" ),
  64.     "labels" => $labels,
  65.     "public" => true,
  66.     "publicly_queryable" => true,
  67.     "hierarchical" => false,
  68.     "show_ui" => true,
  69.     "show_in_menu" => true,
  70.     "show_in_nav_menus" => true,
  71.     "query_var" => true,
  72.     "rewrite" => array( 'slug' => 'runners', 'with_front' => true, ),
  73.     "show_admin_column" => false,
  74.     "show_in_rest" => true,
  75.     "rest_base" => "runners",
  76.     "rest_controller_class" => "WP_REST_Terms_Controller",
  77.     "show_in_quick_edit" => false,
  78.     );
  79.     register_taxonomy( "runners", array( "runners" ), $args );
  80. }
  81. add_action( 'init', 'cptui_register_my_taxes_runners' );
  82.  
  83.  
  84. function ed_charitable_register_futok_field() {
  85.     /**
  86.      * Set up the options that people can choose from in the select field.
  87.      */
  88.  
  89. $terms = get_terms( array(
  90.     'taxonomy' => 'runners',
  91.     'hide_empty' => false,
  92. ) );
  93. $futok[] = pll__('Any');
  94. foreach($terms as $term){
  95. $futok[] = $term->name;
  96. //$futok[$term->slug]=$term->name;
  97.  
  98. }
  99. $futok[] = pll__('Group (21 km above running)');
  100.  
  101.     /**
  102.      * Define a new select field.
  103.      */
  104.     $field = new Charitable_Donation_Field( 'futok_field', array(
  105.         'label' => pll__( 'Choose a runner', 'charitable' ),
  106.         'data_type' => 'user',
  107.         'donation_form' => array(
  108.             'type' => 'select',
  109.             'show_after' => 'email',
  110.             'required' => true,
  111.             'options' => $futok,
  112.         ),
  113.         'admin_form' => true,
  114.         'show_in_meta' => true,
  115.         'show_in_export' => true,
  116.         'email_tag' => array(
  117.             'description' => pll__( 'The runner' ),
  118.         ),
  119.     ) );
  120.     /**
  121.      * Register the select field.
  122.      */
  123.     charitable()->donation_fields()->register_field( $field );
  124. }
  125. add_action( 'init', 'ed_charitable_register_futok_field' );
  126.  
  127. function ed_add_campaign_stats_to_receipt( $donation ) {
  128.     $campaigns = $donation->get_campaign_donations();
  129.     ob_start();
  130.    
  131.     printf( '<h4>%s</h4>', pll__( 'Campaign Stats' ) );
  132.     foreach ( $campaigns as $campaign_donation ) {
  133.         $campaign = charitable_get_campaign( $campaign_donation->campaign_id );        
  134.         printf( '<p><strong>%s</strong></p>', $campaign_donation->campaign_name );
  135.         charitable_template_campaign_donation_summary( $campaign );
  136.     }
  137.     echo ob_get_clean();
  138. }
  139. add_action( 'charitable_donation_receipt_after', 'ed_add_campaign_stats_to_receipt' );
  140.  
  141. ?>
Advertisement
Add Comment
Please, Sign In to add comment