Advertisement
jeffrose

Geodir Custom Field Save example.

Nov 12th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.18 KB | None | 0 0
  1.         public function add_open_close_fields( $post_type = 'gd_place' ){
  2.             $weekdays = array( 'sunday'    => __( 'Sunday', 'gd_business_hours' ),
  3.                                'monday'    => __( 'Monday', 'gd_business_hours' ),
  4.                                'tuesday'   => __( 'Tuesday', 'gd_business_hours' ),
  5.                                'wednesday' => __( 'Wednesday', 'gd_business_hours' ),
  6.                                'thursday'  => __( 'Thursday', 'gd_business_hours' ),
  7.                                'friday'    => __( 'Friday', 'gd_business_hours' ),
  8.                                'saturday'  => __( 'Saturday', 'gd_business_hours' ), );
  9.  
  10.             foreach ( $weekdays as $key => $day ){
  11.                 self::add_day_open_field( $day, $post_type );
  12.                 self::add_day_close_field( $day, $post_type );
  13.             }
  14.         }
  15.  
  16.         private static function add_day_open_field( $day, $post_type ){
  17.             $field = array( 'listing_type'    => $post_type,
  18.                             'data_type'       => 'TIME',
  19.                             'field_type'      => 'time',
  20.                             'admin_title'     => sprintf( __( '%s opening time', 'gd_business_hours' ), $day ),
  21.                             'admin_desc'      => sprintf( __( 'Time location opens on %s', 'gd_business_hours' ), $day ),
  22.                             'site_title'      => sprintf( __( '%s opening time', 'gd_business_hours' ), $day ),
  23.                             'htmlvar_name'    => strtolower( $day ) . '_open',
  24.                             'default_value'   => '',
  25.                             'option_values'   => '',
  26.                             'is_default'      => '0',
  27.                             'is_admin'        => '1',
  28.                             'show_on_listing' => '0',
  29.                             'show_on_detail'  => '0',
  30.                             'clabels'         => sprintf( __( '%s opening time', 'gd_business_hours' ), $day ), );
  31.  
  32.             geodir_custom_field_save( $field );
  33.         }
  34.  
  35.         private static function add_day_close_field( $day, $post_type ){
  36.             $field = array( 'listing_type'    => $post_type,
  37.                             'data_type'       => 'TIME',
  38.                             'field_type'      => 'time',
  39.                             'admin_title'     => sprintf( __( '%s closing time', 'gd_business_hours' ), $day ),
  40.                             'admin_desc'      => sprintf( __( 'Time location closes on %s', 'gd_business_hours' ), $day ),
  41.                             'site_title'      => sprintf( __( '%s closing time', 'gd_business_hours' ), $day ),
  42.                             'htmlvar_name'    => strtolower( $day ) . '_close',
  43.                             'default_value'   => '',
  44.                             'option_values'   => '',
  45.                             'is_default'      => '0',
  46.                             'is_admin'        => '1',
  47.                             'show_on_listing' => '0',
  48.                             'show_on_detail'  => '0',
  49.                             'clabels'         => sprintf( __( '%s closing time', 'gd_business_hours' ), $day ), );
  50.  
  51.             geodir_custom_field_save( $field );
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement