' . esc_html__('Add Pingback', 'addPingbacks') . '' ]; return array_merge($links, $new_links); } return $links; } function add_pingbacks_options_init() { register_setting('addPingbacks-group', 'addPingbacks-options', 'add_pingbacks_validate_input'); } function add_pingbacks_validate_input($input) { return sanitize_text_field($input); } function add_pingbacks_options_link() { add_submenu_page('edit-comments.php', 'Add Pingbacks', 'Add Pingbacks', 'manage_options', 'addPingbacks', 'add_pingbacks_options_page', 'dashicons-admin-comments'); } function add_pingbacks_enqueue_scripts($hook) { if ('comments_page_addPingbacks' !== $hook) { return; } wp_enqueue_script( 'add-pingbacks-js', plugins_url('add-pingbacks.js', __FILE__), array('jquery'), '1.0.0', true ); wp_localize_script( 'add-pingbacks-js', 'wpApiSettings', array('ajaxUrl' => admin_url('admin-ajax.php')) ); } function get_post_types_dropdown() { $post_types = get_post_types(array('public' => true), 'objects'); $options = ''; foreach ($post_types as $post_type) { $options .= ''; } return $options; } function add_post_select_box() { echo ''; echo ''; } function add_pingback_text_box($label, $name, $default = '') { ?> $post_id, 'comment_author' => $author, 'comment_author_email' => $email, 'comment_author_url' => $url, 'comment_content' => $comment, 'comment_type' => 'pingback', 'comment_parent' => 0, 'comment_author_IP' => $ip, 'comment_agent' => 'Add Pingbacks Plugin', 'comment_date' => current_time('mysql'), 'comment_approved' => 1 ]); } function add_pingbacks_options_page() { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'addpingback') { $post_id = intval($_POST['post_list']); $author = !empty($_POST['author_name']) ? sanitize_text_field($_POST['author_name']) : __('anonymous', 'addPingbacks'); $email = !empty($_POST['author_email']) ? sanitize_email($_POST['author_email']) : get_bloginfo('admin_email'); $url = !empty($_POST['author_url']) ? esc_url($_POST['author_url']) : ''; $ip = !empty($_POST['author_ip']) ? sanitize_text_field($_POST['author_ip']) : '127.0.0.1'; $result = add_pingbacks_add_comment($post_id, $author, $email, $url, $ip, sanitize_textarea_field($_POST['comment'])); $message = is_wp_error($result) ? $result->get_error_message() : sprintf(__('Pingback added to %s', 'addPingbacks'), esc_html(get_the_title($post_id))); echo '

' . esc_html($message) . '

'; } ?>


%s', 'addPingbacks'), esc_url('http://simonquasar.net'), esc_attr__('simonquasar', 'addPingbacks'), esc_html__('simonquasar', 'addPingbacks')); ?>
'author_name', 'label' => __('Site Title / Page Name', 'addPingbacks'), 'default' => ''], ['name' => 'author_url', 'label' => __('Link', 'addPingbacks'), 'default' => 'http://'] ]; foreach ($authors as $author) { add_pingback_text_box($author['label'], $author['name'], $author['default']); } ?>

$post_type, 'numberposts' => -1, 'post_status' => 'publish', ]); $response = []; foreach ($posts as $post) { $response[] = [ 'ID' => $post->ID, 'title' => get_the_title($post->ID), ]; } wp_send_json($response); }); add_filter('plugin_row_meta', 'add_pingbacks_set_plugin_meta', 10, 2); add_action('admin_init', 'add_pingbacks_options_init'); add_action('admin_menu', 'add_pingbacks_options_link'); add_action('admin_enqueue_scripts', 'add_pingbacks_enqueue_scripts'); ?>