Using headers in wordpress plugin - wordpress

The wordpress plugin has the following format
<?php
/*
* Plugin Name: XYZ
* Plugin URI: #
* Description: It is used to ..
* Version: 1.1
* License: GPLv2 (or later)
*/
But the text for license does not appear in the admin side's installed list.
for e.g for Akismet - this is the format
Version 2.5.9 | By Automattic | Visit plugin site
The text entered for license does not show up. How can I display the text for license using the wordpress format.
Thanks in Advance

Wordpress ist not showing the license text anywhere.
See: plugin.php

You can use plugin_row_meta filter to add extra row in your plugin listing. See code below for detail:
function set_plugin_meta($links, $file) {
$plugin = plugin_basename(__FILE__);
// create link
if ($file == $plugin) {
return array_merge(
$links,
array( sprintf( 'Your License type', $plugin, __('myplugin') ) )
);
}
return $links;
}
add_filter( 'plugin_row_meta', 'set_plugin_meta', 10, 2 );

Related

How do I execute shortocde in 'Site Title' in WordPress General Settings?

I'm trying to execute [year] shortcode in Site Title to show dynamic year. Created the shortcode using this:
add_shortcode( 'year' , 'current_year' );
function current_year() {
$year = date("Y");
return "$year";
}
Then to execute shortocde, I tried:
add_filter( 'the_title', 'do_shortcode' );
add_filter( 'wp_title', 'do_shortcode' );
But none of them works.
Site Title shows up in the WordPress dashboard (in the top left corner beside WordPress icon), RSS title, in place of the logo (if none is used), and og:site_name in page source.
I'm using the RankMath plugin for SEO if that helps in any way.
<?php
/**
* Plugin Name: Title
* Plugin URI: http://www.deploya.ir
* Description: Do you want a shortcode for Page title?
* Version: 1.0
* Author: Codekit
* Author URI: http://codekit.ir
*/
/* title to get the post title */
/* title to get the post title */
function myshortcode_title( ){
return get_the_title();
}
add_shortcode( 'page_title', 'myshortcode_title' );
I made a plugin with this code to prevent changing function.php from updating each time

Can I create custom post type just for documents like PDF, Video, images? WordPress

What I Have done until now, I am creating a WordPress plugin to add menu page for the document management in WordPress
<?php
/**
*
*
*
* #wordpress-plugin
* Plugin Name: doc management
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/** Step 2 (from text above). */
add_action( 'admin_menu', 'my_plugin_menu' );
/** Step 1. */
function my_plugin_menu() {
add_menu_page( 'My Plugin Options', 'docs Management', 'manage_options', 'my_unique_identifier2', 'my_plugin_options','',4 );
}
/** Step 3. */
function my_plugin_options() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
$file = plugin_dir_path( __FILE__ ) . 'view/main.php';
include_once $file;
}
?>
but I need to add functionality just like in WordPress Post and pages menu. So I am thinking instead of creating a new plugin for the functionality can I do it with custom post type. instead of adding pages or post I just want to add a document. that it's nothing else means instead of adding a new page. add a new document and list all those documents. bulk delete and all.
Is there any specific need that you are trying to build a custom plugin?
I recommend, you may try using https://wordpress.org/plugins/custom-post-type-ui/

Genesis change page slug posts pagination

I'm using Wordpress - Genesis and as Childtheme Enterprise Pro. I love them both but I have one question about pagination slug.
On this page it now is
https://www.hostingportaal.nl/nieuws/page/2/
I want the slug to be:
https://www.hostingportaal.nl/nieuws/pagina/2/
Is it possible to change the slug with a hook or something? Would like to know how I can change this. Help would be very welcome.
Thanks, and keep up the good work. I really love Genesis!
Kind regards,
Joep
This isn't related to using Genesis, or any other particular theme. It's a more general WordPress issue.
https://wordpress.stackexchange.com/questions/57070/change-the-page-slug-in-pagination has a couple of solutions, the first of which is copied and amended here:
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Page to Pagina
* Description: Change <code>/page/</code> to <code>/pagina/</code>.
* Author: Thomas Scholz <info#toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
if ( ! function_exists( 't5_page_to_pagina' ) ) {
register_activation_hook( __FILE__ , 't5_flush_rewrite_on_init' );
register_deactivation_hook( __FILE__ , 't5_flush_rewrite_on_init' );
add_action( 'init', 't5_page_to_pagina' );
function t5_page_to_pagina() {
$GLOBALS['wp_rewrite']->pagination_base = 'pagina';
}
function t5_flush_rewrite_on_init() {
add_action( 'init', 'flush_rewrite_rules', 11 );
}
}

Wordpress WP API Extending - 404 on Endpoints

I'm trying to create a few custom JSON endpoints for my plugin. I installed the WP API plugin and here's the entire contents of my plugin php.
<?php
/**
* Plugin Name: Quiz Wordpress Plugin
* Plugin URI: http://www.domain.com
* Description: This plugin handles quiz functionality.
* Version: 1.0.0
* Author: Ray Hwang
* Author URI: http://www.domain.com
* License: private
*/
function quiz_api_init() {
global $quiz_api;
$quiz_api = new QUIZ_API();
add_filter( 'json_endpoints', array( $quiz_api, 'register_routes' ) );
}
add_action( 'wp_json_server_before_serve', 'quiz_api_init' );
class QUIZ_API {
public function register_routes( $routes ) {
$routes['/api'] = array(
array( array( $this, 'get_quiz'), WP_JSON_Server::READABLE ),
array( array( $this, 'new_quiz'), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ),
);
return $routes;
}
public function get_quiz($_headers, $data = ''){
return array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
}
public function new_quiz($_headers, $data = ''){
return array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
}
}
There are no errors when I activate the plugin. When I request the endpoint. I get
Not Found
The requested URL /api was not found on this server.
Apache/2.4.7 (Ubuntu) Server at ec2-----.compute-1.amazonaws.com Port 80
Does it have something to do with URL rewrite or permalinks?
My permalink settings is set to default http://ec2--------.compute-1.amazonaws.com/?p=123
You will need to ensure you've gone into permalink settings and saved to force the rewrite rules to be written again.
Also a great tool I use during my plugin development to ensure that the rewrite rules are actually applied is Rewrite Rules Inspector it'll list all your current rules including your new endpoints if they have been added.

How can I disable WordPress plugin updates?

I've found a great plugin for WordPress under GPLv2 license and made a lot of changes in source code, plugin does something else now.
I modified author (with original plugin author's credits), URL, version number (from xxx 1.5 to YYY 1.0).
Everything works great, but when WordPress checks for plugin updates it treats my plugin YYY 1.0 as xxx 1.0 and displays notification about available update.
My changed plugin YYY 1.0 was installed by copying files from my computer, not from WP repository.
What else do I have to change?
Disable plugin update
Add this code in your plugin root file.
add_filter('site_transient_update_plugins', 'remove_update_notification');
function remove_update_notification($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}
Put this code in the theme functions.php file. This is working for me and I'm using it. Also this is for specific plugin. Here you need to change plugin main file url to match to that of your plugin.
function my_filter_plugin_updates( $value ) {
if( isset( $value->response['facebook-comments-plugin/facebook-comments.php'] ) ) {
unset( $value->response['facebook-comments-plugin/facebook-comments.php'] );
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
Here:
"facebook-comments-plugin" => facebook comments plugin folder name
"facebook-comments.php" => plugin main file.this may be different like index.php
Hope this would be help.
The simplest and effective way is to change the version of the plugin which you don't want to get update.
For an example
if I don't want wptouch to get updated, I open it's defination file, which is like:
/*
Plugin Name: WPtouch Mobile Plugin
Plugin URI: http://www.wptouch.com/
Version: 4.0.4
*/
Here in the Version change 4.0.4 to 9999
like:
/*
Plugin Name: WPtouch Mobile Plugin
Plugin URI: http://www.wptouch.com/
Version: 9999
*/
In the plugin file, there will be a function that will check for updates. The original author could have named this anything, so you will have to go through the code and check each function and what it does. I would imagine the function will be quite obvious as to what it does.
Alternatively you can add this to your plugin file:
add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[$my_plugin] );
unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
$r['body']['plugins'] = serialize( $plugins );
}
return $r;
}
Credits: http://developersmind.com/2010/06/12/preventing-wordpress-from-checking-for-updates-for-a-plugin/
add_filter('site_transient_update_plugins', '__return_false');
in function.php add above code and disable all plugins updates
Add this line to wp-config.php to disable plugin updates:
define('DISALLOW_FILE_MODS',true);
One easy solution was to change the version of plugin in plugin file.
For example if plugin version is 1.2.1. You can make it like below (100.9.5 something that plugin author will never reach to )
<?php
/*
* Plugin Name: Your Plugin Name
* Description: Plugin description.
* Version: 100.9.5
*/
Here's an updated version of Mark Jaquith's script:
WP Updates have switched to HTTPS
Unserialize was blocked on my shared hosting
This uses json_decode and json_encode instead
Credit: Block Plugin Update
.
add_filter( 'http_request_args', 'widget_disable_update', 10, 2 );
function widget_disable_update( $r, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = json_decode( $r['body']['plugins'], true );
unset( $plugins['plugins'][$my_plugin] );
unset( $plugins['active'][array_search( $my_plugin, $plugins['active'] )] );
$r['body']['plugins'] = json_encode( $plugins );
}
return $r;
}
Disable plugin updates manually:
Open functions.php file (go to your activated themes folder)
Copy and paste the following code:
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
Save changes, and you’re done
Just for completeness, here is one more plugin meant to block updates of selected other plugins:
https://github.com/daggerhart/lock-plugins
Some information about its background and mode of function can be found here (in German).

Resources