plugin_name . '_init_scripts', array( $this, 'uploader_js' ) ); // include styles to Admin UI Interface add_action( $this->plugin_name . '_init_styles', array( $this, 'uploader_style' ) ); } } /*-----------------------------------------------------------------------------------*/ /* admin_uploader_url */ /*-----------------------------------------------------------------------------------*/ public function admin_uploader_url() { if ( $this->admin_uploader_url ) return $this->admin_uploader_url; return $this->admin_uploader_url = untrailingslashit( plugins_url( '/', __FILE__ ) ); } /*-----------------------------------------------------------------------------------*/ /* Include Uploader Script */ /*-----------------------------------------------------------------------------------*/ public function uploader_js () { wp_enqueue_script( 'a3-uploader-script', $this->admin_uploader_url() . '/uploader-script.js', array( 'jquery', 'thickbox' ), $this->framework_version ); if ( function_exists( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } else { wp_enqueue_script('media-upload'); } } /*-----------------------------------------------------------------------------------*/ /* Include Uploader Style */ /*-----------------------------------------------------------------------------------*/ public function uploader_style () { wp_enqueue_style( 'thickbox' ); wp_enqueue_style( 'a3-uploader-style', $this->admin_uploader_url() . '/uploader.css', array(), $this->framework_version ); if ( is_rtl() ) { wp_enqueue_style( 'a3-uploader-style-rtl', $this->admin_uploader_url() . '/uploader.rtl.css', array(), $this->framework_version ); } } /*-----------------------------------------------------------------------------------*/ /* Get Upload Input Field */ /*-----------------------------------------------------------------------------------*/ public function upload_input ( $name_attribute, $id_attribute = '', $value = '', $attachment_id = 0, $default_value = '', $field_name = '', $class = '', $css = '', $description = '', $strip_methods = true ) { $output = ''; if ( trim( $value ) == '' ) $value = trim( $default_value ); if ( strstr( $name_attribute, ']' ) ) { $attachment_id_name_attribute = substr_replace( $name_attribute, '_attachment_id', -1, 0 ); } else { $attachment_id_name_attribute = $name_attribute.'_attachment_id'; } if ( $strip_methods === false ) { $strip_methods = 0; } else { $strip_methods = 1; } $output .= ''; $output .= ' '; $output .= ' '.$description; $output .= '
'; if ( $value != '' ) { $remove = ' '; $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value ); if ( $image ) { $output .= ''.$remove.''; } else { $parts = explode( "/", $value ); for( $i = 0; $i < sizeof( $parts ); ++$i ) { $title = $parts[$i]; } $output .= ''; $title = __( 'View File', 'a3-portfolio' ); $output .= '
'.$title.''.$remove.'
'; } } $output .= '
'; return $output; } } global $a3_portfolio_uploader; $a3_portfolio_uploader = new A3_Portfolio_Uploader(); ?>