class-affiliates-banner.php
19.5 KB
<?php
class Affiliates_Banner { public static function init() { add_action( 'init', array( __CLASS__, 'wp_init' ), 11 ); add_action( 'admin_init', array(__CLASS__, 'admin_init' ) ); add_shortcode( 'affiliates_banner', array( __CLASS__, 'affiliates_banner_shortcode' ) ); add_filter( 'media_view_strings', array( __CLASS__, 'media_view_strings' ), 10, 2 ); add_filter( 'upload_dir', array(__CLASS__,'upload_dir' ) ); } public static function admin_init() { global $pagenow; add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ), 10, 2 ); add_filter( 'enter_title_here', array( __CLASS__, 'enter_title_here' ), 10, 2 ); add_action( 'edit_form_after_title', array( __CLASS__, 'edit_form_after_title' ) ); add_action( 'save_post', array( __CLASS__, 'save_post' ), 10, 2 ); add_filter( 'post_row_actions', array( __CLASS__, 'post_row_actions' ) ); add_filter( 'post_updated_messages', array( __CLASS__, 'post_updated_messages' ) ); add_filter( 'manage_affiliates_banner_posts_columns', array( __CLASS__, 'posts_columns' ) ); add_filter( 'manage_edit-affiliates_banner_columns', array( __CLASS__, 'edit_affiliates_banner_columns' ) ); add_filter( 'manage_affiliates_banner_posts_custom_column', array( __CLASS__, 'posts_custom_column' ), 10, 2 ); add_action( 'current_screen', array(__CLASS__, 'current_screen' ) ); add_filter( 'parent_file', array( __CLASS__, 'parent_file' ) ); $IXAP392 = isset( $_REQUEST['screen_id'] ) ? $_REQUEST['screen_id'] : ''; $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; if ( isset( $pagenow ) && ( $pagenow == 'admin-ajax.php' ) && ( ( $IXAP392 == 'affiliates_banner' ) || ( $action == 'set-post-thumbnail' ) ) ) { if ( !has_filter( 'gettext', array( __CLASS__, 'gettext' ) ) ) { add_filter( 'gettext', array( __CLASS__, 'gettext' ), 10, 3 ); } } } public static function current_screen() { $IXAP351 = get_current_screen(); if ( isset( $IXAP351->id ) ) { switch( $IXAP351->id ) { case 'edit-affiliates_banner' : case 'affiliates_banner' : if ( !has_filter( 'gettext', array( __CLASS__, 'gettext' ) ) ) { add_filter( 'gettext', array( __CLASS__, 'gettext' ), 10, 3 ); } break; } } } public static function parent_file( $parent_file ) { global $submenu_file; switch ( $submenu_file ) { case 'post-new.php?post_type=affiliates_banner' : case 'edit.php?post_type=affiliates_banner' : $parent_file = 'affiliates-admin'; $submenu_file = 'edit.php?post_type=affiliates_banner'; break; } return $parent_file; } public static function media_view_strings( $IXAP393, $post ) { if ( isset( $post->post_type ) && ( $post->post_type == 'affiliates_banner' ) ) { $IXAP393['setFeaturedImageTitle'] = __( 'Set Banner Image', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP393['setFeaturedImage'] = __( 'Set banner image', AFFILIATES_PRO_PLUGIN_DOMAIN ); } return $IXAP393; } public static function gettext( $IXAP394, $IXAP395, $IXAP396 ) { remove_filter( 'gettext', array( __CLASS__, 'gettext' ) ); switch( $IXAP395 ) { case '(no title)' : $IXAP394 = __( '(no reference)', AFFILIATES_PRO_PLUGIN_DOMAIN ); break; case 'Set featured image' : $IXAP394 = __( 'Set banner image', AFFILIATES_PRO_PLUGIN_DOMAIN ); break; case 'Remove featured image' : $IXAP394 = __( 'Remove banner image', AFFILIATES_PRO_PLUGIN_DOMAIN ); break; } add_filter( 'gettext', array( __CLASS__, 'gettext'), 10, 3 ); return $IXAP394; } public static function posts_columns( $posts_columns ) { foreach( $posts_columns as $IXAP78 => $IXAP87 ) { switch( $IXAP78 ) { case 'title' : $posts_columns[$IXAP78] = __( 'Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ); break; } } return $posts_columns; } public static function edit_affiliates_banner_columns( $IXAP261 ) { if ( isset( $IXAP261['date'] ) ) { $IXAP132 = $IXAP261['date']; unset( $IXAP261['date'] ); } $IXAP261['image'] = __( 'Image', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP261['shortcode'] = __( 'Shortcode', AFFILIATES_PRO_PLUGIN_DOMAIN ); if ( isset( $IXAP132 ) ) { $IXAP261['date'] = $IXAP132; } return $IXAP261; } public static function posts_custom_column( $IXAP397, $post_id ) { global $IXAP398; if ( !isset( $IXAP398 ) ) { $IXAP398 = true; echo '<style type="text/css">'; echo 'th.column-title { width: 15%; }'; echo 'td.image.column-image { overflow: hidden; }'; echo '</style>'; } switch( $IXAP397 ) { case 'image' : $IXAP399 = get_the_post_thumbnail( $post_id ); if ( empty( $IXAP399 ) ) { $IXAP399 = self::get_url_thumbnail( $post_id ); } printf( '<a href="%s">%s</a>', esc_attr( get_edit_post_link( $post_id ) ), $IXAP399 ); break; case 'shortcode' : echo '<p>'; printf( __( '<code>[affiliates_banner id="%d"]</code>', AFFILIATES_PRO_PLUGIN_DOMAIN ), $post_id ); echo '</p>'; break; } } public static function get_url_thumbnail( $post_id ) { $IXAP163 = get_post_meta( $post_id, 'url', true ); $IXAP400 = get_post_meta( $post_id, 'width', true ); $IXAP401 = get_post_meta( $post_id, 'height', true ); list( $IXAP400, $IXAP401 ) = image_constrain_size_for_editor( $IXAP400, $IXAP401, $IXAP402 = 'thumbnail' ); $IXAP399 = sprintf( '<img src="%s" width="%d" height="%d" />', $IXAP163, $IXAP400, $IXAP401 ); return $IXAP399; } public static function get_url_image( $post_id, $IXAP403 ) { $IXAP163 = get_post_meta( $post_id, 'url', true ); $IXAP400 = get_post_meta( $post_id, 'width', true ); $IXAP401 = get_post_meta( $post_id, 'height', true ); $IXAP404 = sprintf( '<img src="%s" width="%d" height="%d" alt="%s" />', $IXAP163, intval( $IXAP400 ), intval( $IXAP401 ), esc_attr( $IXAP403 ) ); return $IXAP404; } public static function wp_init() { self::post_type(); } public static function post_type() { register_post_type( 'affiliates_banner', array( 'labels' => array( 'name' => __( 'Banners', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'singular_name' => __( 'Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'all_items' => __( 'Banners', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'add_new' => __( 'New Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'add_new_item' => __( 'Add New Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'edit' => __( 'Edit', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'edit_item' => __( 'Edit Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'new_item' => __( 'New Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'not_found' => __( 'No Banners found', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'not_found_in_trash' => __( 'No Banners found in trash', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'parent' => __( 'Parent Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'search_items' => __( 'Search Banners', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'view' => __( 'View Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'view_item' => __( 'View Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'menu_name' => __( 'Banners', AFFILIATES_PRO_PLUGIN_DOMAIN ) ), 'capability_type' => array( 'affiliates_banner', 'affiliates_banners' ), 'description' => __( 'Affiliate Banner', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'exclude_from_search' => true, 'has_archive' => false, 'hierarchical' => false, 'map_meta_cap' => true, 'public' => false, 'publicly_queryable' => false, 'query_var' => true, 'rewrite' => false, 'show_in_nav_menus' => false, 'show_ui' => true, 'supports' => array( 'title', 'thumbnail' ), 'show_in_menu' => false, ) ); self::create_capabilities(); } public static function create_capabilities() { global $wp_roles; $IXAP405 = $wp_roles->get_role( 'administrator' ); $IXAP406 = self::get_capabilities(); foreach( $IXAP406 as $IXAP78 => $IXAP407 ) { if ( !$IXAP405->has_cap( $IXAP407 ) ) { $IXAP405->add_cap( $IXAP407 ); } } } public static function get_capabilities() { return array( 'edit_posts' => 'edit_affiliates_banners', 'edit_others_posts' => 'edit_others_affiliates_banners', 'publish_posts' => 'publish_affiliates_banners', 'read_private_posts' => 'read_private_affiliates_banners', 'delete_posts' => 'delete_affiliates_banners', 'delete_private_posts' => 'delete_private_affiliates_banners', 'delete_published_posts' => 'delete_published_affiliates_banners', 'delete_others_posts' => 'delete_others_affiliates_banners', 'edit_private_posts' => 'edit_private_affiliates_banners', 'edit_published_posts' => 'edit_published_affiliates_banners', ); } public static function add_meta_boxes( $post_type, $post ) { if ( $post_type == 'affiliates_banner' ) { remove_meta_box( 'postimagediv', 'affiliates_banner', 'side' ); add_meta_box( 'postimagediv', __( 'Banner Image', AFFILIATES_PRO_PLUGIN_DOMAIN ), array( __CLASS__, 'post_thumbnail_meta_box' ), 'affiliates_banner', 'normal', 'high' ); add_meta_box( 'url', __( 'URL', AFFILIATES_PRO_PLUGIN_DOMAIN ), array( __CLASS__, 'url_meta_box' ), 'affiliates_banner', 'normal', 'high' ); } } public static function enter_title_here( $IXAP81, $post ) { if ( $post->post_type == 'affiliates_banner' ) { return __( 'Banner reference …', AFFILIATES_PRO_PLUGIN_DOMAIN ); } return $IXAP81; } public static function edit_form_after_title( $post ) { if ( isset( $post->post_type ) && $post->post_type == 'affiliates_banner' ) { echo '<div style="padding:2px 1em 1em 1em;" class="description">'; echo '<p>'; echo __( 'The reference for this banner (also used as <em>alt</em> attribute for images specified by URL).', AFFILIATES_PRO_PLUGIN_DOMAIN ); echo '</p>'; echo '<p>'; echo __( 'Set a banner image and determine its title and other attributes directly for the image attachment using the <strong>Banner Image</strong> facilities.', AFFILIATES_PRO_PLUGIN_DOMAIN ); echo '</p>'; if ( isset( $post->ID ) ) { echo '<p>'; printf( __( 'Use this shortcode to embed the banner: <code>[affiliates_banner id="%d"]</code>', AFFILIATES_PRO_PLUGIN_DOMAIN ), $post->ID ); echo '</p>'; } echo '</div>'; } } public static function url_meta_box( $post ) { $IXAP62 = ''; $IXAP163 = get_post_meta( $post->ID, 'url', true ); $IXAP400 = get_post_meta( $post->ID, 'width', true ); $IXAP401 = get_post_meta( $post->ID, 'height', true ); $IXAP408 = get_post_meta( $post->ID, 'update_size', true ); if ( empty( $IXAP408 ) ) { $IXAP408 = 'yes'; } $IXAP62 .= '<div>'; $IXAP62 .= '<p>'; $IXAP62 .= __( 'Alternatively, a banner image URL can be specified.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= ' '; $IXAP62 .= __( 'This is useful if you want to use an external image or an image that is located outside the uploads directory structure.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= ' '; $IXAP62 .= __( 'If a banner image is set, it takes precedence - this is only used if no banner image is set.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</p>'; $IXAP62 .= '</div>'; $IXAP62 .= '<div>'; $IXAP62 .= self::get_url_thumbnail( $post->ID ); $IXAP62 .= '</div>'; $IXAP62 .= '<div>'; $IXAP62 .= '<label>'; $IXAP62 .= __( 'URL', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= ' '; $IXAP62 .= sprintf( '<input style="display:block; width:100%%" type="text" name="url" value="%s" />', esc_attr( $IXAP163 ) ); $IXAP62 .= '</label>'; $IXAP62 .= '<p class="description">'; $IXAP62 .= __( 'Banner image URL.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</p>'; $IXAP62 .= '</div>'; $IXAP62 .= '<div>'; $IXAP62 .= '<label>'; $IXAP62 .= sprintf( '<input type="checkbox" name="update_size" value="1" %s />', $IXAP408 == 'yes' ? ' checked="checked" ' : '' ); $IXAP62 .= ' '; $IXAP62 .= __( 'Update Size', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</label>'; $IXAP62 .= '<p class="description">'; $IXAP62 .= __( 'Try to obtain the image width and height based on the URL and update the values.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</p>'; $IXAP62 .= '</div>'; $IXAP62 .= '<div>'; $IXAP62 .= '<label>'; $IXAP62 .= __( 'Width', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= ' '; $IXAP62 .= sprintf( '<input style="display:block; width:5em" type="text" name="width" value="%s" />', esc_attr( $IXAP400 ) ); $IXAP62 .= '</label>'; $IXAP62 .= '<p class="description">'; $IXAP62 .= __( 'Banner image width in pixels.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</p>'; $IXAP62 .= '</div>'; $IXAP62 .= '<div>'; $IXAP62 .= '<label>'; $IXAP62 .= __( 'Height', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= ' '; $IXAP62 .= sprintf( '<input style="display:block; width:5em" type="text" name="height" value="%s" />', esc_attr( $IXAP401 ) ); $IXAP62 .= '</label>'; $IXAP62 .= '<p class="description">'; $IXAP62 .= __( 'Banner image height in pixels.', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</p>'; $IXAP62 .= '</div>'; echo $IXAP62; } public static function save_post( $post_id = null, $post = null ) { if ( ! ( ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) ) ) { if ( $post->post_type == 'affiliates_banner' ) { if ( $post->post_status != 'auto-draft' ) { if ( isset( $_REQUEST['action'] ) && ( $_REQUEST['action'] == 'inline-save' ) ) { return; } $IXAP163 = !empty( $_POST['url'] ) ? trim( $_POST['url'] ) : ''; delete_post_meta( $post_id, 'url' ); if ( !empty( $IXAP163 ) ) { add_post_meta( $post_id, 'url', $IXAP163 ); } $IXAP408 = !empty( $_POST['update_size'] ) ? 'yes' : 'no'; delete_post_meta( $post_id, 'update_size' ); add_post_meta( $post_id, 'update_size', $IXAP408 ); $IXAP400 = null; $IXAP401 = null; if ( $IXAP408 == 'yes' ) { if ( !empty( $IXAP163 ) ) { if ( $IXAP402 = getimagesize( $IXAP163 ) ) { if ( isset( $IXAP402[0] ) ) { $IXAP400 = $IXAP402[0]; } if ( isset( $IXAP402[1] ) ) { $IXAP401 = $IXAP402[1]; } } } } if ( $IXAP400 === null ) { $IXAP400 = !empty( $_POST['width'] ) ? intval( trim( $_POST['width'] ) ) : 0; } delete_post_meta( $post_id, 'width' ); if ( $IXAP400 > 0 ) { add_post_meta( $post_id, 'width', $IXAP400 ); } if ( $IXAP401 === null ) { $IXAP401 = !empty( $_POST['height'] ) ? intval( trim( $_POST['height'] ) ) : 0; } delete_post_meta( $post_id, 'height' ); if ( $IXAP401 > 0 ) { add_post_meta( $post_id, 'height', $IXAP401 ); } } } } } public static function post_row_actions( $actions ) { $post_type = get_post_type(); if ( $post_type == 'affiliates_banner' ) { unset( $actions['view'] ); } return $actions; } public static function post_updated_messages( $messages ) { $post = get_post(); $messages['affiliates_banner'] = array( 0 => '', 1 => __( 'Banner updated.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 2 => __( 'Custom field updated.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 3 => __( 'Custom field deleted.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 4 => __( 'Banner updated.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Banner restored to revision from %s', AFFILIATES_PRO_PLUGIN_DOMAIN ), wp_post_revision_title( ( int ) $_GET['revision'], false ) ) : false, 6 => __( 'Banner published.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 7 => __( 'Banner saved.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 8 => __( 'Banner submitted.', AFFILIATES_PRO_PLUGIN_DOMAIN ), 9 => sprintf( __( 'Banner scheduled for: <strong>%1$s</strong>.', AFFILIATES_PRO_PLUGIN_DOMAIN ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ) ), 10 => __( 'Banner draft updated.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); return $messages; } public static function affiliates_banner_shortcode( $IXAP223, $IXAP167 = '' ) { $IXAP105 = shortcode_atts( array( 'id' => '*', 'url' => '', 'render' => '' ), $IXAP223 ); $IXAP62 = ''; $IXAP163 = trim( $IXAP105['url'] ); $IXAP144 = trim( $IXAP105['id'] ); $IXAP108 = trim( $IXAP105['render'] ); $IXAP409 = array_map( 'trim', explode( ',', $IXAP163 ) ); $post_ids = array(); if ( trim( $IXAP144 ) == '*' ) { $posts = get_posts( array( 'numberposts' => -1, 'post_type' => 'affiliates_banner', 'post_status' => 'publish' ) ); foreach( $posts as $post ) { if ( get_post_thumbnail_id( $post->ID ) || get_post_meta( $post->ID, 'url', true ) ) { $post_ids[] = $post->ID; } } } else { $post_ids = array_map( 'intval', array_map( 'trim', explode( ',', $IXAP144 ) ) ); } $IXAP410 = array(); $IXAP80 = 0; foreach( $post_ids as $post_id ) { if ( isset( $IXAP409[$IXAP80] ) ) { if ( !empty( $IXAP409[$IXAP80] ) ) { $IXAP410['url'] = $IXAP409[$IXAP80]; } } $IXAP163 = Affiliates_Url_Renderer_WordPress::render_affiliate_url( $IXAP410 ); add_filter( 'wp_get_attachment_image_attributes', array( __CLASS__, 'wp_get_attachment_image_attributes' ), 999, 2 ); $IXAP404 = get_the_post_thumbnail( $post_id, 'full', array( 'class' => '' ) ); if ( empty( $IXAP404 ) ) { $IXAP403 = get_the_title( $post_id ); $IXAP404 = self::get_url_image( $post_id, $IXAP403 ); } $IXAP411 = sprintf( '<a href="%s">%s</a>', esc_attr( $IXAP163 ), $IXAP404 ); remove_filter( 'wp_get_attachment_image_attributes', array( __CLASS__, 'wp_get_attachment_image_attributes' ) ); $IXAP62 .= apply_filters( 'affiliates_banner_before', '', $IXAP223 ); $IXAP62 .= '<div class="affiliates-banner">'; if ( empty( $IXAP108 ) || ( $IXAP108 == 'image' ) ) { $IXAP62 .= apply_filters( 'affiliates_banner_image_before', '', $IXAP144, $IXAP163, $IXAP223 ); $IXAP62 .= apply_filters( 'affiliates_banner_image', '<div class="banner-image">' . $IXAP404 . '</div>', $IXAP144, $IXAP163, $IXAP223 ); $IXAP62 .= apply_filters( 'affiliates_banner_image_after', '', $IXAP144, $IXAP163, $IXAP223 ); } if ( empty( $IXAP108 ) || ( $IXAP108 == 'code' ) ) { $IXAP62 .= apply_filters( 'affiliates_banner_code_before', '', $IXAP144, $IXAP163, $IXAP223 ); $IXAP62 .= apply_filters( 'affiliates_banner_code', '<div class="banner-code">' . '<code>' . htmlentities( $IXAP411 ) . '</code>' . '</div>', $IXAP144, $IXAP163, $IXAP223 ); $IXAP62 .= apply_filters( 'affiliates_banner_code_after', '', $IXAP144, $IXAP163, $IXAP223 ); } $IXAP62 .= '</div>'; $IXAP62 .= apply_filters( 'affiliates_banner_after', '', $IXAP223 ); $IXAP80++; } $IXAP62 = apply_filters( 'affiliates_banner', $IXAP62, $IXAP223 ); return $IXAP62; } public static function wp_get_attachment_image_attributes( $IXAP412, $IXAP413 ) { unset( $IXAP412['class'] ); return $IXAP412; } public static function post_thumbnail_meta_box( $post ) { $IXAP414 = get_post_meta( $post->ID, '_thumbnail_id', true ); echo self::_wp_post_thumbnail_html( $IXAP414, $post->ID ); } public static function _wp_post_thumbnail_html( $IXAP414 = null, $post = null ) { global $IXAP415, $IXAP416; $post = get_post( $post ); $IXAP417 = esc_url( get_upload_iframe_src('image', $post->ID ) ); $IXAP418 = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set banner image', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>'; $IXAP167 = sprintf( $IXAP418, $IXAP417, esc_html__( 'Set banner image', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); if ( $IXAP414 && get_post( $IXAP414 ) ) { $IXAP419 = $IXAP415; $IXAP415 = 266; if ( !isset( $IXAP416['full'] ) ) { $IXAP420 = wp_get_attachment_image( $IXAP414, array( $IXAP415, $IXAP415 ) ); } else { $IXAP420 = wp_get_attachment_image( $IXAP414, 'full' ); } if ( !empty( $IXAP420 ) ) { $IXAP421 = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); $IXAP167 = sprintf( $IXAP418, $IXAP417, $IXAP420 ); $IXAP167 .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $IXAP421 . '\');return false;">' . esc_html__( 'Remove banner image', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</a></p>'; } $IXAP415 = $IXAP419; } return apply_filters( 'admin_post_thumbnail_html', $IXAP167, $post->ID ); } public static function upload_dir( $IXAP35 ) { global $post, $post_id; if ( empty( $post_id ) ) { if ( !empty( $post ) && isset( $post->ID ) ) { $post_id = $post->ID; } else { $post_id = !empty( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : null; } } if ( !empty( $post_id ) && ( get_post_type( $post_id ) == 'affiliates_banner' ) ) { if ( apply_filters( 'affiliates_banner_empty_subdir', true ) ) { $IXAP35['subdir'] = ''; $IXAP35['path'] = $IXAP35['basedir'] . '/banners'; $IXAP35['url'] = $IXAP35['baseurl'] . '/banners'; } else { if ( empty( $IXAP35['subdir'] ) ) { $IXAP35['path'] = $IXAP35['path'] . '/banners'; $IXAP35['url'] = $IXAP35['url'] . '/banners'; $IXAP35['subdir'] = '/banners'; } else { $IXAP422 = '/banners' . $IXAP35['subdir']; $IXAP35['path'] = str_replace( $IXAP35['subdir'], $IXAP422, $IXAP35['path'] ); $IXAP35['url'] = str_replace( $IXAP35['subdir'], $IXAP422, $IXAP35['url'] ); $IXAP35['subdir'] = str_replace( $IXAP35['subdir'], $IXAP422, $IXAP35['subdir'] ); } } } return $IXAP35; } } Affiliates_Banner::init();