Note that there are some explanatory texts on larger screens.

plurals
  1. POwp_schedule_event hook is not working
    text
    copied!<p>I am working on a plugin and want to add a cron to it so I have added following code, but it is not executing at all, please check it and correct it for me if needed. If code is correct then how can I debug it ? Note: acp poster was defined early in file.</p> <pre><code>add_action( 'wp_loaded', 'prefix_setup_schedule' ); function prefix_setup_schedule($record) { if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) { wp_schedule_event( time(), 'hourly', 'prefix_hourly_event',$record); } } add_action( 'prefix_hourly_event', 'ACP_poster' ); </code></pre> <p>here is ACP_poster function:</p> <pre><code>function ACP_poster($n){ global $wpdb,$api_key; $row = $wpdb-&gt;get_results('SELECT a,b,c FROM tbname ORDER BY id DESC LIMIT 1',ARRAY_A); $url = 'https://example.com'; $headers = array( 'Authorization' =&gt; $api_key ); $request = new WP_Http; $result = $request-&gt;request( $url , array( 'method' =&gt; 'GET', 'headers' =&gt; $headers, 'sslverify' =&gt; false ) ); $data = new SimpleXMLElement($result['body']); $attributes = $data-&gt;p-&gt;attributes(); foreach ($data-&gt;p[0] as $p) { // Sanitize data. $pr = number_format((float)$p-&gt;pr, 2, '.', ' '); $image = '&lt;a href="'.$p-&gt;{'url2'}.'"&gt;&lt;img src="'.$p-&gt;{'url3'} .'" style="float: right"/&gt;&lt;/a&gt;'; $pd = $image.$p-&gt;description .'-- ='.$p-&gt;currency.' '. ' ,Retail Price ='.$p-&gt;{'retail-price'}.' , '. $p-&gt;{'sale-price'}.'&lt;a href="'.$p-&gt;{'url2'}. '"&gt;...&lt;/a&gt;'; $v = $c[$no]-&gt;child; $ids = get_term_by('slug', $v, 'category');//wordpress function $id = (int)$ids-&gt;term_taxonomy_id; $p2 = array('post_title' =&gt; $p-&gt;name, 'post_content' =&gt; $pd, 'post_status' =&gt; 'publish', 'post_author' =&gt; 1, 'post_category' =&gt;array($id)); $pr = wp_insert_post( $p2, $wp_error ); wp_reset_query(); // Restore global post data stomped by the_post(). } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload