/** * Add all the hooks */ public function add_hooks() { $hooks = gnt_get_hooks(); $hook_settings = gnt_get_hook_settings(); foreach ($hooks as $hook) { add_action('gnt_hook_' . $hook['slug'], array($this, 'send')); } }
/** * Prepare the items for output * * @return null */ function prepare_items() { $columns = $this->get_columns(); $hidden = array(); $sortable = array(); $this->_column_headers = array($columns, $hidden, $sortable); $this->hook_settings = gnt_get_hook_settings(); $this->items = gnt_get_hooks(); }
/** * Show the Hooks page content * @return null */ function gnt_hooks_page_content() { $hooks = gnt_get_hooks(); $hook_settings = gnt_get_hook_settings(); // Save the settings if (isset($_POST['submit']) && check_admin_referer('gnt_save_hooks')) { gnt_save_hook_settings($_POST); gnt_force_redirect($_POST['_wp_http_referer']); } include_once GET_NOTIFIED_PLUGIN_DIR . 'views/hooks.php'; }
/** * Post status change * * @param string $new_status The new status of the post * @param string $old_status The old statud of the post * @param WP_Post $post The WP_Post object * @return null */ function post_status_change($new_status, $old_status, $post) { $post_statuses = get_post_stati(); $hook_settings = gnt_get_hook_settings(); foreach ($post_statuses as $post_status) { if (isset($hook_settings['post_status_' . $post_status . '-enable']) && $hook_settings['post_status_' . $post_status . '-enable']) { if ($old_status !== $post_status && $new_status === $post_status) { do_action('gnt_hook_post_status_' . $post_status, array('hook' => 'post_' . $post_status, 'text' => $post->post_title . __(' changed status to ', 'get-notified') . $post_status, 'post' => $post, 'post_status' => $post_status)); } } } }
/** * Test to make sure the settings we get are an array * @return null */ function test_get_hook_settings() { $hook_settings = gnt_get_hook_settings(); $this->assertTrue(is_array($hook_settings)); }