"; foreach ($images as $image) { ?>
  • "; exit(); } } add_action( 'admin_init', 'register_ad_itt_upload_settings' ); function register_ad_itt_upload_settings() { $uploadfiles = $_FILES['uploadfiles']; if (is_array($uploadfiles)) { foreach ($uploadfiles['name'] as $key => $value) { // look only for uploded files if ($uploadfiles['error'][$key] == 0) { $filetmp = $uploadfiles['tmp_name'][$key]; //clean filename and extract extension $filename = $uploadfiles['name'][$key]; // get file info // @fixme: wp checks the file extension.... $filetype = wp_check_filetype( basename( $filename ), null ); $filetitle = preg_replace('/\.[^.]+$/', '', basename( $filename ) ); $filename = $filetitle . '.' . $filetype['ext']; $upload_dir = wp_upload_dir(); /** * Check if the filename already exist in the directory and rename the * file if necessary */ $i = 0; while ( file_exists( $upload_dir['path'] .'/' . $filename ) ) { $filename = $filetitle . '_' . $i . '.' . $filetype['ext']; $i++; } $filedest = $upload_dir['path'] . '/' . $filename; /** * Check write permissions */ if ( !is_writeable( $upload_dir['path'] ) ) { $this->msg_e('Unable to write to directory %s. Is this directory writable by the server?'); return; } /** * Save temporary file to uploads dir */ if ( !@move_uploaded_file($filetmp, $filedest) ){ $this->msg_e("Error, the file $filetmp could not moved to : $filedest "); continue; } $attachment = array( 'post_mime_type' => $filetype['type'], 'post_title' => $filetitle, 'post_content' => '', 'post_status' => 'inherit', ); $attach_id = wp_insert_attachment( $attachment, $filedest ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filedest ); wp_update_attachment_metadata( $attach_id, $attach_data ); preg_match("/\/wp-content(.+)$/", $filedest, $matches, PREG_OFFSET_CAPTURE); AdIttTomM8::update_record_by_id("posts", array("guid" => get_option("siteurl").$matches[0][0]), "ID", $attach_id); echo $filedest; } } } } function ad_itt_activate() { add_option( "css_content_wrapper_selector", "", "", "yes" ); add_option( "enable_left_ad_link", "", "", "yes" ); add_option( "left_ad_link", "", "", "yes" ); add_option( "left_ad_img", "", "", "yes" ); add_option( "left_ad_position", "", "", "yes" ); add_option( "enable_right_ad_link", "", "", "yes" ); add_option( "right_ad_link", "", "", "yes" ); add_option( "right_ad_img", "", "", "yes" ); add_option( "right_ad_position", "", "", "yes" ); add_option( "enable_top_ad_link", "", "", "yes" ); add_option( "top_ad_link", "", "", "yes" ); add_option( "top_ad_img", "", "", "yes" ); add_option( "top_ad_retract_time", "", "", "yes" ); add_option( "top_ad_close_img", "", "", "yes" ); add_option( "top_ad_position", "", "", "yes" ); add_option( "enable_bottom_ad_link", "", "", "yes" ); add_option( "bottom_ad_link", "", "", "yes" ); add_option( "bottom_ad_img", "", "", "yes" ); add_option( "bottom_ad_position", "", "", "yes" ); } register_activation_hook( __FILE__, 'ad_itt_activate' ); add_action('admin_menu', 'register_ad_itt_page'); function register_ad_itt_page() { add_menu_page('Ad Itt', 'Ad Itt', 'manage_options', 'ad-itt/ad-itt.php', 'ad_itt_settings_page'); } //call register settings function add_action( 'admin_init', 'register_ad_itt_settings' ); function register_ad_itt_settings() { //register our settings register_setting( 'ad-itt-group', 'css_content_wrapper_selector' ); register_setting( 'ad-itt-group', 'enable_left_ad_link' ); register_setting( 'ad-itt-group', 'left_ad_link' ); register_setting( 'ad-itt-group', 'left_ad_img' ); register_setting( 'ad-itt-group', 'left_ad_position' ); register_setting( 'ad-itt-group', 'enable_right_ad_link' ); register_setting( 'ad-itt-group', 'right_ad_link' ); register_setting( 'ad-itt-group', 'right_ad_img' ); register_setting( 'ad-itt-group', 'right_ad_position' ); register_setting( 'ad-itt-group', 'enable_top_ad_link' ); register_setting( 'ad-itt-group', 'top_ad_link' ); register_setting( 'ad-itt-group', 'top_ad_img' ); register_setting( 'ad-itt-group', 'top_ad_retract_time' ); register_setting( 'ad-itt-group', 'top_ad_close_img' ); register_setting( 'ad-itt-group', 'top_ad_position' ); register_setting( 'ad-itt-group', 'enable_bottom_ad_link' ); register_setting( 'ad-itt-group', 'bottom_ad_link' ); register_setting( 'ad-itt-group', 'bottom_ad_img' ); register_setting( 'ad-itt-group', 'bottom_ad_position' ); } function are_ad_itt_dependencies_installed() { return is_plugin_active("jquery-colorbox/jquery-colorbox.php"); } add_action( 'admin_notices', 'ad_itt_notice_notice' ); function ad_itt_notice_notice(){ $activate_nonce = wp_create_nonce( "activate-ad-itt-dependencies" ); $jquery_colorbox = is_plugin_active("jquery-colorbox/jquery-colorbox.php"); if (!($jquery_colorbox)) { ?>

    Before you can use Ad Itt, please install/activate:

    Ad Itt Updated

    Ad Itt

    0%

    Ad Itt

    Enable/Disable
    Example: #content, #main-content, .content
    />
    Sets the width of image as 100%.
    />
    Sets the width of image as 100%.
    />
    Sets the width of image as 221px.
    />
    Sets the width of image as 221px.

    get_option("css_content_wrapper_selector"), "enable_left_ad_link" => get_option("enable_left_ad_link"), "left_ad_link" => get_option("left_ad_link"), "left_ad_img" => get_option("left_ad_img"), "left_ad_position" => get_option("left_ad_position"), "enable_right_ad_link" => get_option("enable_right_ad_link"), "right_ad_link" => get_option("right_ad_link"), "right_ad_img" => get_option("right_ad_img"), "right_ad_position" => get_option("right_ad_position"), "enable_top_ad_link" => get_option("enable_top_ad_link"), "top_ad_link" => get_option("top_ad_link"), "top_ad_img" => get_option("top_ad_img"), "top_ad_retract_time" => get_option("top_ad_retract_time"), "top_ad_close_img" => get_option("top_ad_close_img"), "top_ad_position" => get_option("top_ad_position"), "enable_bottom_ad_link" => get_option("enable_bottom_ad_link"), "bottom_ad_link" => get_option("bottom_ad_link"), "bottom_ad_img" => get_option("bottom_ad_img"), "bottom_ad_position" => get_option("bottom_ad_position") ) ); wp_register_style( 'my-ad-itt-style', plugins_url('/css/ad-itt.css?20130115b', __FILE__) ); wp_enqueue_style('my-ad-itt-style'); } ?>