window.top.location='".get_permalink( get_option('Acud_thanks_page'))."';";
wp_redirect(get_permalink( get_option('Acud_thanks_page')),301);
echo "";
wp_die();
}
add_action('wp_ajax_AcuD_fail', 'wp_ajax_AcuD_fail_callback');
add_action('wp_ajax_nopriv_AcuD_fail', 'wp_ajax_AcuD_fail_callback');
function wp_ajax_AcuD_fail_callback() {
wp_redirect(get_permalink( get_option('Acud_thanks_page') ));
echo "";
wp_die();
}
add_filter('the_content', 'AcuD_filter_post');
function AcuD_filter_post( $text ){
if (is_page(get_option('Acud_rules_page')) && get_option('Acud_is_gratitude_OnRules') =='1'){
$text .= '
';
return $text;
}
if (!is_single())
{
return $text;
}
$Acud_logo_after_post = get_option("Acud_logo_after_post");
$Acud_logo_befor_post = get_option("Acud_logo_befor_post");
if($Acud_logo_after_post == "1"){
$text = $text . do_shortcode('[AcuD_donate float="'.get_option("Acud_logo_after_post_select").'"]');
}
if($Acud_logo_befor_post == "1") {
$text = do_shortcode('[AcuD_donate float="'.get_option("Acud_logo_befor_post_select").'"]') . $text;
}
return $text;
}
add_action('plugins_loaded', 'AcuD_textdomain');
function AcuD_textdomain(){
load_textdomain('AcuD_transl',__DIR__ ."/languages/AcuD_".get_locale().'.mo');
}
function AcuD_Plugin_activ(){
load_textdomain('AcuD_transl',__DIR__ ."/languages/AcuD_".get_locale().'.mo');
global $wpdb;
$wp_upload_dir = wp_upload_dir();
$logos_files = array('AcuD_logo_imgID'=>'AcuD_logo_2.jpg','AcuD_popUp_img_level_2'=>'AcuD_middle.jpg','AcuD_popUp_img_level_1'=>'AcuD_pit-stop_2.jpg','AcuD_popUp_img_level_3'=>'AcuD_cafe.jpg');
foreach ($logos_files as $key =>$file) {//добавляем фалы по-умолчанию
$filename = $wp_upload_dir['basedir'] .'/4-author-cheer-up-donate/'. $file;
$id = $wpdb->get_var("SELECT id FROM ".$wpdb->prefix."posts WHERE post_title = '".preg_replace('/\.[^.]+$/', '', basename($filename))."';");
if( $id == NULL) {
mkdir($wp_upload_dir['basedir'] . '/4-author-cheer-up-donate/', 0755);
rename(plugin_dir_path(__FILE__) . 'logos/' . $file, $filename);
$attachment = array(
'guid' => $wp_upload_dir['baseurl'] . '/4-author-cheer-up-donate/' . basename($filename),
'post_mime_type' => 'image/jpeg',
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment($attachment, $filename);
wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $filename));
add_option($key, $attach_id);// текст в popUP под товарами
}
else
{
add_option($key, $id);
}
}
foreach (glob(plugin_dir_path(__FILE__) . 'logos/*') as $key =>$file) {//добавляем все остальные
$filename = $wp_upload_dir['basedir'] .'/4-author-cheer-up-donate/'. basename($file);
$id = $wpdb->get_var("SELECT id FROM ".$wpdb->prefix."posts WHERE post_title = '".preg_replace('/\.[^.]+$/', '', basename($filename))."';");
if( $id == NULL) {
mkdir($wp_upload_dir['basedir'] . '/4-author-cheer-up-donate/', 0755);
rename($file, $filename);
$attachment = array(
'guid' => $wp_upload_dir['baseurl'] . '/4-author-cheer-up-donate/' . basename($filename),
'post_mime_type' => 'image/jpeg',
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment($attachment, $filename);
wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $filename));
}
}
add_option('Acud_mrh_login');//индетификатор магазина
add_option('Acud_mrh_pass1');//пароль #1
add_option('Acud_mrh_pass2');//пароль #2
add_option('Acud_mrh_pass1_test');// тестовый пароль #1
add_option('Acud_mrh_pass2_test');// тестовый пароль #2
add_option('Acud_mrh_isTest',0);// чекбокс тестовых паролей
add_option('Acud_logo_size',12);// размер лого в процентах
add_option('Acud_logo_after_post',1);// лого после поста
add_option('Acud_logo_after_post_select','right');// и его местоположение
add_option('Acud_logo_befor_post',0);// лого перед постос
add_option('Acud_logo_befor_post_select','left');// и его местоположение
add_option('Acud_text_logo',__('May you will treat a tired author a cup of coffee?','AcuD_transl'));//ID картинки лого
add_option('AcuD_popUp_main_text',__('Did you like the material? You can treat the author of a cup of aromatic coffee and leave him a good wish ("Thanks").
Your cup will be delivered to the author. A cup of coffee is not much, but it warms and gives strength to create further. You can choose to treat a author.
','AcuD_transl'));// теск в popUP над товарами
add_option('AcuD_popUp_text_level_1',__('A cup of coffee with PitStop for 50 rubles.','AcuD_transl'));// текст в popUP под товарами
add_option('AcuD_popUp_text_level_2',__('A cup of coffee with a gas station for 100 rubles.','AcuD_transl'));// текст в popUP под товарами
add_option('AcuD_popUp_text_level_3',__('A cup of coffee with a Cafe for 150 rubles.','AcuD_transl'));// текст в popUP под товарами
add_option('Acud_is_rules',1);// показ сылки на правила использования
add_option('Acud_is_gratitude',1);// показ благодарности
add_option('Acud_is_gratitude_OnRules',1);// показ благодарности на странице правил
add_option('Acud_is_gratitude_OnThanks',1);// показ благодарности на странице Спасибо
$defaults = array(
'post_title' => __('Terms of use','AcuD_transl'),
'post_content' => __('1. All the funds pay you, when using this plugin, will be considered a donation.
2. Your donation is voluntary.
3. All donations are transferred to the author for personal use on the terms of the site.
4. No one can demand a donation back.
5. If you did not have the right to make a donation - contact the site administration urgently.
','AcuD_transl'),
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => get_current_user_id(),
'ping_status' => get_option('default_ping_status'),
'post_parent' => 0,
'menu_order' => 0,
'to_ping' => '',
'pinged' => '',
'post_password' => '',
'guid' => '',
'post_content_filtered' => '',
'post_excerpt' => '',
'import_id' => 0
);
add_option('Acud_rules_page',wp_insert_post( $defaults ));// показ сылки на правила использования
$defaults = array(
'post_title' => __('Page "Thanks"','AcuD_transl'),
'post_content' => '[AcuD_thank_you]',
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => get_current_user_id(),
'ping_status' => get_option('default_ping_status'),
'post_parent' => 0,
'menu_order' => 0,
'to_ping' => '',
'pinged' => '',
'post_password' => '',
'guid' => '',
'post_content_filtered' => '',
'post_excerpt' => '',
'import_id' => 0
);
add_option('Acud_thanks_page',wp_insert_post( $defaults ));// страница спсибо
$wpdb->query(//создание таблицы сохраненых полей если такой несуществует
"
CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."acud_thank_names
(
id int UNSIGNED NOT NULL PRIMARY KEY auto_increment,
nameUser varchar(100) NOT NULL ,
text text,
Price varchar(100) NOT NULL,
`success` TINYINT NOT NULL DEFAULT 0,
`from_url` VARCHAR(2300) NULL
);");
}
register_activation_hook( __FILE__,'AcuD_Plugin_activ');
?>