";
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);
tom_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' );
@check_ad_itt_dependencies_are_active(
"Ad Itt",
array(
"Tom M8te" => array("plugin"=>"tom-m8te/tom-m8te.php", "url" => "http://downloads.wordpress.org/plugin/tom-m8te.zip", "version" => "1.1"),
"JQuery Colorbox" => array("plugin"=>"jquery-colorbox/jquery-colorbox.php", "url" => "http://downloads.wordpress.org/plugin/jquery-colorbox.zip"))
);
}
function ad_itt_settings_page() {
?>
Sorry for the confusion but you must install and activate ";
$plugins_array = array();
$upgrades_array = array();
define('PLUGINPATH', ABSPATH.'wp-content/plugins');
foreach ($dependencies as $key => $value) {
$plugin = get_plugin_data(PLUGINPATH."/".$value["plugin"],true,true);
$url = $value["url"];
if (!is_plugin_active($value["plugin"])) {
array_push($plugins_array, $key);
} else {
if (isset($value["version"]) && str_replace(".", "", $plugin["Version"]) < str_replace(".", "", $value["version"])) {
array_push($upgrades_array, $key);
}
}
}
$msg_content .= implode(", ", $plugins_array) . " before you can use $plugin_name. Please go to Plugins/Add New and search/install the following plugin(s): ";
$download_plugins_array = array();
foreach ($dependencies as $key => $value) {
if (!is_plugin_active($value["plugin"])) {
$url = $value["url"];
array_push($download_plugins_array, $key);
}
}
$msg_content .= implode(", ", $download_plugins_array)."
";
if (count($plugins_array) > 0) {
deactivate_plugins( __FILE__, true);
echo($msg_content);
}
if (count($upgrades_array) > 0) {
deactivate_plugins( __FILE__,true);
echo "$plugin_name requires the following plugins to be updated: ".implode(", ", $upgrades_array).".
";
}
}
add_action('wp_head', 'add_ad_itt_js_and_css');
function add_ad_itt_js_and_css() {
wp_enqueue_script('jquery');
?>
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');
} ?>