PHP and Wordpress, run a script every time you make a new post

0

Hello, I'm needing every time I make a new post in Wordpress run a script . I do not want to waste time making applications, I just want to know which page is responsible for sending the posts in Wordpress. I also want to know if you can get Título da postagem to pass as a parameter every time you have a new post.

How do I do this quickly?

The reason for this? I need to run a script that I myself did to send push notifications. I just need every time I make a new post run the script with Título da postagem .

If you can help me; Thank you, thank you.

[EDIT] I found the name of the Wordpress file, it's called post.php and it's in the wp-admin folder, now I need to know where I put the email script and how I get the title post.php

    
asked by anonymous 18.03.2015 / 18:30

1 answer

1

Use this function to return a booleano value:

function is_edit_page($new_edit = null){
    global $pagenow;
    //certifique-se de que estamos no backend
    if (!is_admin()) return false;


    if($new_edit == "edit")

        return in_array( $pagenow, array( 'post.php',  ) );

    elseif($new_edit == "new") //check for new post page
        return in_array( $pagenow, array( 'post-new.php' ) );

    else // verifica se há é uma nova postagem ou foi editada
        return in_array( $pagenow, array( 'post.php', 'post-new.php' ) );
}

Now we will use the conditionals to validate:

if (is_edit_page()){
   //sim, é uma edição ou nova página de postagem
}

Checking if it's a new post (HERE'S YOUR E-MAIL SCRIPT)

if (is_edit_page('new')){
   //sim é uma nova postagem

}

Checking if it was edited only:

if (is_edit_page('edit')){
   //sim é uma nova postagem
}

Read more ...

    
18.03.2015 / 22:08