رفتن به مطلب

لطفا برای ساخت این پلاگین کمکم کنید.


mgh67

پست های پیشنهاد شده

من می خوام یک پلاگین ساده بسازم که هرگاه یک پست جدید (نه صفحه جدید )ایجاد شد و منتشر شد(نه ذخیره در پیشنویس) یک کلاس اجرا کند اما هرکاری می کنم نه اروری داده می شود و نه کلاس اجراء می شود .


add_action( 'publish_post', 'send_post' );
add_filter ( 'publish_post', 'send_post' );
function send_post($post_ID){
$meta_values = get_post_meta($post_ID, 'is_notified', true);
if($meta_values!='yes'){
$pub_post = get_post($post_ID);global $wpdb;
$post_title=$pub_post->post_title;
if ($pub_post->post_status == 'publish')
{
if($pub_post->post_type=="post")
{
$pluginName = 'bitly/bitly.php';
if (is_plugin_active($pluginName)) {
remove_all_filters('post_link');
}
if($post_thumbnail_id!="")
{
$first_img=wp_get_attachment_url(get_post_thumbnail_id( $post_ID ));
}
else
{
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postpp->post_content, $matches);
$first_img = $matches [1] [0];
}
$content = $postpp->post_content;
$title = $postpp->post_title;
$content = preg_replace("/(<)([img])(\w+)([^>]*>)/", "", $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content=strip_tags($content);
$content=html_entity_decode($content, "UTF-8");
$title = preg_replace("/(<)([img])(\w+)([^>]*>)/", "", $title);
$title = apply_filters('the_content', $title);
$title = str_replace(']]>', ']]>', $title);
$title=strip_tags($title);
$title=html_entity_decode($title, "UTF-8");
$title=substr($title, 0, 50);
$des=substr($content, 0, 100);
//publish post
$my_var = new Myclass();
$my_var->Setcontent($title,$des,$content,$first_img);
if($my_var->Send())
{
$response="ok";
}
else
{
$response="Your server";
}
$time=time();
$post_options=array(
'postid'=>$post_ID,
'publishtime'=>$time,
'status'=>$response."TEXT"
);
update_option('post_logs', $post_options);
}
}
if($Rreturns){
add_post_meta($post_ID, 'is_notified', 'yes');
}
}
}

لینک به ارسال

لطفا برای ارسال دیدگاه وارد شوید

شما بعد از اینکه وارد حساب کاربری خود شدید می توانید دیدگاهی ارسال کنید



ورود به حساب کاربری
×
×
  • اضافه کردن...