| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | function get_epl_image_sizes() { |
| 24: | return apply_filters( |
| 25: | 'epl_image_sizes', |
| 26: | array( |
| 27: | array( |
| 28: | 'id' => 'admin-list-thumb', |
| 29: | 'height' => 100, |
| 30: | 'width' => 100, |
| 31: | 'crop' => true, |
| 32: | ), |
| 33: | array( |
| 34: | 'id' => 'epl-image-medium-crop', |
| 35: | 'height' => 400, |
| 36: | 'width' => 600, |
| 37: | 'crop' => true, |
| 38: | ), |
| 39: | ) |
| 40: | ); |
| 41: | } |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | function epl_image_sizes() { |
| 50: | |
| 51: | $epl_sizes = get_epl_image_sizes(); |
| 52: | |
| 53: | foreach ( $epl_sizes as $epl_size ) { |
| 54: | add_image_size( $epl_size['id'], $epl_size['width'], $epl_size['height'], $epl_size['crop'] ); |
| 55: | } |
| 56: | } |
| 57: | add_action( 'after_setup_theme', 'epl_image_sizes' ); |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | function epl_image_size_names_choose( $epl_sizes ) { |
| 69: | return array_merge( |
| 70: | $epl_sizes, |
| 71: | array( |
| 72: | 'epl-image-medium-crop' => __( 'Medium 600x400 hard Crop', 'easy-property-listings' ), |
| 73: | ) |
| 74: | ); |
| 75: | } |
| 76: | add_filter( 'image_size_names_choose', 'epl_image_size_names_choose' ); |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | function epl_property_author_archives( $query ) { |
| 85: | |
| 86: | if ( $query->is_author ) { |
| 87: | $query->set( 'post_type', array( 'directory', 'rental', 'testimonial', 'property', 'post' ) ); |
| 88: | } |
| 89: | |
| 90: | |
| 91: | remove_action( 'pre_get_posts', 'epl_property_author_archives' ); |
| 92: | } |
| 93: | add_action( 'pre_get_posts', 'epl_property_author_archives' ); |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | function epl_custom_post_author_archive( $query ) { |
| 102: | if ( $query->is_author ) { |
| 103: | $query->set( 'post_type', array( 'property', 'rental', 'testimonial', 'post', 'commercial', 'land' ) ); |
| 104: | } |
| 105: | |
| 106: | remove_action( 'pre_get_posts', 'epl_custom_post_author_archive' ); |
| 107: | } |
| 108: | add_action( 'pre_get_posts', 'epl_custom_post_author_archive' ); |
| 109: | |
| 110: | |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | function epl_populate_post_author_email( $value ) { |
| 126: | |
| 127: | if ( is_author() ) { |
| 128: | $author = get_queried_object(); |
| 129: | if ( $author instanceof WP_User ) { |
| 130: | return $author->user_email; |
| 131: | } |
| 132: | } |
| 133: | |
| 134: | global $post; |
| 135: | if ( $post instanceof WP_Post ) { |
| 136: | $author_email = get_the_author_meta( 'user_email', $post->post_author ); |
| 137: | if ( ! empty( $author_email ) ) { |
| 138: | return $author_email; |
| 139: | } |
| 140: | } |
| 141: | |
| 142: | return ''; |
| 143: | } |
| 144: | add_filter( 'gform_field_value_author_email', 'epl_populate_post_author_email' ); |
| 145: | |
| 146: | |
| 147: | |
| 148: | |
| 149: | |
| 150: | |
| 151: | |
| 152: | |
| 153: | |
| 154: | |
| 155: | |
| 156: | |
| 157: | function epl_populate_secondary_author_email( $value ) { |
| 158: | global $property; |
| 159: | |
| 160: | if ( ! $property instanceof EPL_Property_Meta ) { |
| 161: | return ''; |
| 162: | } |
| 163: | |
| 164: | $agent_id = epl_listing_has_secondary_agent(); |
| 165: | |
| 166: | return $agent_id ? (string) get_the_author_meta( 'user_email', $agent_id ) : ''; |
| 167: | } |
| 168: | add_filter( 'gform_field_value_author_email_secondary', 'epl_populate_secondary_author_email' ); |
| 169: | |
| 170: | |
| 171: | |
| 172: | |
| 173: | |
| 174: | |
| 175: | |
| 176: | |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | function epl_populate_primary_agent_email( $value ) { |
| 182: | global $epl_author; |
| 183: | |
| 184: | return ( is_object( $epl_author ) && ! empty( $epl_author->email ) ) ? (string) $epl_author->email : ''; |
| 185: | } |
| 186: | add_filter( 'gform_field_value_primary_agent_email', 'epl_populate_primary_agent_email' ); |
| 187: | |
| 188: | |
| 189: | |
| 190: | |
| 191: | |
| 192: | |
| 193: | |
| 194: | |
| 195: | |
| 196: | |
| 197: | |
| 198: | function epl_populate_primary_agent_name( $value ) { |
| 199: | global $epl_author; |
| 200: | |
| 201: | return ( is_object( $epl_author ) && ! empty( $epl_author->name ) ) ? (string) $epl_author->name : ''; |
| 202: | } |
| 203: | add_filter( 'gform_field_value_primary_agent_name', 'epl_populate_primary_agent_name' ); |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: | |
| 209: | |
| 210: | |
| 211: | |
| 212: | |
| 213: | |
| 214: | |
| 215: | function epl_populate_property_unique_id( $value ) { |
| 216: | global $property; |
| 217: | |
| 218: | return $property instanceof EPL_Property_Meta ? (string) $property->get_property_meta( 'property_unique_id' ) : ''; |
| 219: | } |
| 220: | add_filter( 'gform_field_value_property_unique_id', 'epl_populate_property_unique_id' ); |
| 221: | |
| 222: | |
| 223: | |
| 224: | |
| 225: | |
| 226: | |
| 227: | |
| 228: | |
| 229: | |
| 230: | |
| 231: | |
| 232: | function epl_populate_property_office_id( $value ) { |
| 233: | global $property; |
| 234: | |
| 235: | return $property instanceof EPL_Property_Meta ? (string) $property->get_property_meta( 'property_office_id' ) : ''; |
| 236: | } |
| 237: | add_filter( 'gform_field_value_property_office_id', 'epl_populate_property_office_id' ); |
| 238: | |