Add content externally into wordpress pages - wordpress

I'm wondering if this is possible in wordpress, I would like a user to edit text for a post/page on another site, or instance of the main wordpress site and then update the text which would then change on the main site. I want the user to see just plain text and no wordpress admin editing areas.

External Page: Create an HTML form and send the data to Your WordPress page.
Pseudo-Code (do not forget to add security!):
In WordPress functions.php:
add_action('init','check_external_submission');
function check_external_submission() {
if(isset($_POST["ext"]) && $_POST["ext"] != "") {
wp_insert_post(array("post_content" => $_POST["content"], "post_title" => $_POST["title"]);
die;
}
}
Check wp_insert_post function here:
https://codex.wordpress.org/Function_Reference/wp_insert_post

Related

How to Add .html to the End of a WordPress URL and hide /product-category/

I use the Remove Taxonomy Base Slug plugin to hide in the url /product-category/
For example site.ru/product-category/cars/sport/bmw make site.ru/cars/sport/bmw
the plugin does a good job with it, but it's impossible to add everywhere to the end of the url .html to have site.ru/cars/sport/bmw.html instead of site.ru/product-category/cars/sport/bmw
site.ru/cars.html instead of site.ru/product-category/cars
In the settings of permanent links installed /%postname%.html
but it still does not work, it seems because of the rules of the plugin
Yes, We can hide and show category into URL with .html extension into a page. I was developing one plugin for .html URL for WordPress.
check plugin and add your comment. also, we provide support.
Plugin linn Wordpress add .htmli into custom post and category list page
Sample Code :
function jn_htmlInUrl_page_permalink() {
global $wp_rewrite;
if ( in_array( 'page', $this->selected_post_type ) ) {
if ( ! strpos( $wp_rewrite->get_page_permastruct(), '.html' ) ) {
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
}
$wp_rewrite->flush_rules();
}
if you fetching issues and comment here or plugin details page.
i will try to help resolve issues

Wordpress admin - add item next to "Activate Edit Delete" list

In the plugins section of the admin screen, each plugin generally has a list of a few things you can do, usually "activate, edit, delete". How can I add an item to this list?
In your plugin file just add this code.
// Add settings link on plugin page
function your_plugin_settings_link($links) {
$settings_link = 'Settings';
array_unshift($links, $settings_link);
return $links;
}
$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_$plugin", 'your_plugin_settings_link' );
EDIT: OK so i guess you are administrating the sites, and you want your users to report if something goes wrong with any plugin. Here are some of the options.
Use Jquery to add links.
Use the above function and add a loop around the add_filter, and then loop through `$all_plugins = get_plugins();

How to add page URL to list of pages in WordPress admin panel?

Currently, by default, the following columns appear in the list of pages in the WordPress admin panel:
Title
Author
Comments
Date
and because I have AIO SEO installed:
SEO Title
SEO Description
SEO Keywords
Is there a way to have WordPress also display the URL to the page (at least the part of the URL that is created when the page itself is created)?
The page url is actually already there by default, it's just hiding. When you hover over a page title, several links appear below the title -- edit, quick edit, trash, view. View is the hyperlink to the page, which you can click to view the page, or right click and copy the link address to use elsewhere.
Otherwise, if you are using a custom/child theme, you could add the following to your functions.php file:
add_filter('manage_page_posts_columns', 'my_custom_column', 10);
add_action('manage_page_posts_custom_column', 'add_my_custom_column', 10, 2);
function my_custom_column($defaults) {
$defaults['url'] = 'URL';
return $defaults;
}
function add_my_custom_column($column_name, $post_id) {
if ($column_name == 'url') {
echo get_permalink( $post_id );
}
}
Note: This just creates a text url to your page.
Also note, you do not want to edit your functions.php file directly if you are using a theme you did not create, as it will be overwritten when you update. If you want to add this to an existing theme, I'd suggest looking into child themes.
This is helpful. I would only improve the output slightly by removing the site url and just showing the page. Takes up less space and less to weed through visually.
if ($column_name == 'url') {
$siteURL=get_site_url($post_id);
$link= get_permalink( $post_id );
echo str_replace($siteURL,"",$link);
}

Redirecting from Custom Admin Page Produces "Headers already sent"

I've registered a custom Admin page in my plugin through add_submenu_page. In the callback function (the one that generates the contents of the admin page), I have the following code:
wp_redirect('http://google.com');
exit;
However, when I visit the admin page I get an error:
Warning: Cannot modify header information - headers already sent by (output started at ..\wp-admin\includes\template.php:1637) in ..\wp-includes\pluggable.php on line 878
The callback from add_submenu_page happens too late (after the admin sidebar and header are rendered), this is why the location header can not be sent anymore.
To accomplish this, we need to hook a function a bit earlier in the WordPress admin area, before the headers are sent (e.g. admin_init).
A good way:
function myplugin_preprocess_pages($value){
global $pagenow;
$page = (isset($_REQUEST['page']) ? $_REQUEST['page'] : false);
if($pagenow=='admin.php' && $page=='myplugin-custom-page-slug'){
wp_redirect('http://google.com');
exit;
}
}
add_action('admin_init', 'myplugin_preprocess_pages');
The above code will redirect you to Google whenever you try to view wp-admin/admin.php?page=myplugin-custom-page-slug.
In my case, I've attached the custom page via add_submenu_page to the default (admin.php) parent in the Admin area and I've set the custom page's slug to myplugin-custom-page-slug. Feel free to replace the values in the code above or even add a PHP switch if you have a lot of custom admin pages.
This way we have hooked early enough to do a redirection whenever our custom admin page is viewed.
Update: (A different approach)
Thanks to this post, I've learned that WordPress creates a unique action that you can hook to for each custom admin page (load-{parent_page_slug}_page_{plugin_subpage_slug}). For example, if you've added a custom admin page with parent admin.php and slug myplugin-custom-page, you can hook to its "load" action in the following manner:
add_action( 'load-admin_page_myplugin-custom-page', 'myplugin_custom_page_redirect' );
function myplugin_custom_page_redirect() {
if ( 'myplugin-custom-page' == filter_input( INPUT_GET, 'page' ) ) {
wp_redirect( 'http://google.com' );
exit;
}
}
Note that the action name has some things to consider. It's a mixture of underscores and dashes and make sure you only include the parent page's name without the extension (so "admin" instead of "admin.php")

Override WordPress [gallery] shortcode insertion with different name

Say you created your own Gallery plugin that uses it's own shortcode (eg: [my_gallery] )
How would you go about modifying the default WordPress gallery shortcode insertion within the editor of [gallery] to [my_gallery] so that the client is not confused with having to remember the custom shortcode and accidentally making incorrect gallery insertions?
first remove the gallery shortcode , and then add your own ...
remove_shortcode('gallery', 'gallery_shortcode'); // removes the original shortcode
add_shortcode('gallery', 'my_awesome_gallery_shortcode'); // add your own shortcode
function my_awesome_gallery_shortcode($attr) {
$output = 'Codex is your friend' ;
return $output;
}
or as an alternative just rename your shortcode to something less confusing :-)

Resources