mods in the comments header, date and version number
This commit is contained in:
parent
fef643345c
commit
e3936a91a0
|
@ -1,90 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* The plugin bootstrap file
|
||||
*
|
||||
* This file is read by WordPress to generate the plugin information in the plugin
|
||||
* admin area. This file also includes all of the dependencies used by the plugin,
|
||||
* registers the activation and deactivation functions, and defines a function
|
||||
* that starts the plugin.
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
* @package Plugin_Name
|
||||
*
|
||||
* @wordpress-plugin
|
||||
*/
|
||||
|
||||
/*
|
||||
Plugin Name: Biofriction - website options
|
||||
Plugin URI: https://biofriction.org/
|
||||
Description: All the <strong>options</strong> for <strong>Biofriction website</strong> wich do not come by default with wordpress such as: selector for showing buttons, a date picker for old posts, and any other needs.
|
||||
Version: 0.3
|
||||
Author URI: https://vitrubio.net/
|
||||
Author: jorge - vitrubio.net
|
||||
License: GPL 3.0
|
||||
Date: 2020 02 10
|
||||
License URI:https://www.gnu.org/licenses/gpl-3.0.html
|
||||
Text Domain: bfr_plugin_txtdomain
|
||||
Domain Path: /languages
|
||||
* Plugin Name
|
||||
*
|
||||
* @package Biofriction - website options
|
||||
* @author jorge - vitrubio.net
|
||||
* @copyright 2021 jorge - vitrubio.net & hangar.org
|
||||
* @license GPL-3.0-or-later
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: Biofriction - website options
|
||||
* Plugin URI: https://git.hangar.org/hangar-tech/biofriction-wp-plugin
|
||||
* Description: All the <strong>options</strong> for <strong>Biofriction website</strong> wich do not come by default with wordpress such as: selector for showing buttons, a date picker for old posts, and any other needs.
|
||||
* Version: 0.4
|
||||
* Date: 2021 11 24
|
||||
* Requires at least: 5.2
|
||||
* Requires PHP: 7.2
|
||||
* Author: jorge - vitrubio.net
|
||||
* Author URI: https://vitrubio.net/
|
||||
* Text Domain: bfr_plugin_txtdomain
|
||||
* Domain Path: /languages
|
||||
* License: GPL 3.0
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* Update URI: https://git.hangar.org/hangar-tech/biofriction-wp-theme.git
|
||||
*/
|
||||
|
||||
/*
|
||||
if ever read this never forget to check
|
||||
howto write a pluggin by Wordpress.org
|
||||
https://codex.wordpress.org/Writing_a_Plugin
|
||||
https://developer.wordpress.org/plugins/
|
||||
and the best practices
|
||||
https://developer.wordpress.org/plugins/plugin-basics/best-practices/
|
||||
and some resources
|
||||
https://themefoundation.com/wordpress-meta-boxes-guide/
|
||||
*/
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/* *
|
||||
* Load translation, if it exists
|
||||
* * * * * * * * * * * * * * * * * * */
|
||||
|
||||
function bfr_plugin_init() {
|
||||
// Load translation, if it exists
|
||||
function bfr_plugin_init() {
|
||||
$plugin_dir = basename(dirname(__FILE__));
|
||||
load_plugin_textdomain( 'bfr_plugin_txtdomain', null, $plugin_dir.'/assets/languages/' );
|
||||
}
|
||||
add_action('plugins_loaded', 'bfr_plugin_init');
|
||||
}
|
||||
add_action('plugins_loaded', 'bfr_plugin_init');
|
||||
|
||||
/* *
|
||||
* add settings link in pluggin page
|
||||
* * * * * * * * * * * * * * * * * * */
|
||||
function bfr_plugin_plugin_action_links($links, $file) {
|
||||
// add settings link in pluggin page
|
||||
function bfr_plugin_plugin_action_links($links, $file) {
|
||||
$this_plugin = basename(plugin_dir_url(__FILE__)) . '/bfr-theme-plugin.php';
|
||||
if($file == $this_plugin) {
|
||||
$links[] = '<a href="admin.php?page=biofriction-options">' . __('Settings', 'bfr_plugin_txtdomain') . '</a>';
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
add_filter('plugin_action_links', 'bfr_plugin_plugin_action_links', 10, 2);
|
||||
}
|
||||
add_filter('plugin_action_links', 'bfr_plugin_plugin_action_links', 10, 2);
|
||||
|
||||
/**
|
||||
* Registers stylesheet for a custom plugin.
|
||||
*/
|
||||
// Registers stylesheet for a custom plugin.
|
||||
function biofriction_theme_plugin_styles_admin() {
|
||||
add_editor_style( 'assets/css/bfr-theme-plugin.css' );
|
||||
}
|
||||
add_action( 'admin_init', 'biofriction_theme_plugin_styles_admin' );
|
||||
|
||||
/**
|
||||
* Proper way to enqueue scripts and styles
|
||||
*/
|
||||
// enqueue scripts and styles
|
||||
function biofriction_theme_plugin_styles_public() {
|
||||
$this_plugin = basename(plugin_dir_url(__FILE__));
|
||||
wp_enqueue_style( 'bfr-theme-plugin', plugin_dir_url(__FILE__) . 'assets/css/bfr-theme-plugin.css' );
|
||||
// wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
|
||||
wp_enqueue_style( 'bfr-theme-plugin', plugin_dir_url(__FILE__) . 'assets/css/bfr-theme-plugin.css' , array(), filemtime( plugin_dir_url(__FILE__) . 'assets/css/bfr-theme-plugin.css' ), 'all');
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'biofriction_theme_plugin_styles_public' );
|
||||
|
||||
/* *
|
||||
* Custom button in TINYMCE editor for styling
|
||||
* * * * * * * * * * * * * * * * * * * * * * */
|
||||
// as read on
|
||||
// https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_buttons,_mce_buttons_2,_mce_buttons_3,_mce_buttons_4
|
||||
/* *
|
||||
* Custom button in TINYMCE editor for styling
|
||||
* * * * * * * * * * * * * * * * * * * * * * */
|
||||
// as read on
|
||||
// https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_buttons,_mce_buttons_2,_mce_buttons_3,_mce_buttons_4
|
||||
// https://www.wpbeginner.com/wp-tutorials/how-to-add-custom-styles-to-wordpress-visual-editor/
|
||||
// https://kinsta.com/blog/wordpress-tinymce-editor/
|
||||
|
||||
|
@ -95,7 +77,7 @@ if ( ! function_exists( 'bfr_mce_buttons' ) ) :
|
|||
// array_unshift( $buttons, 'styleselect', 'removeformat' );
|
||||
array_push( $buttons, 'styleselect', 'removeformat' );
|
||||
return $buttons;
|
||||
}
|
||||
}
|
||||
endif;
|
||||
// Register our callback to the appropriate filter
|
||||
add_filter( 'mce_buttons_2', 'bfr_mce_buttons' );
|
||||
|
@ -162,19 +144,19 @@ add_filter( 'tiny_mce_before_init', 'bfr_mce_before_init_insert_formats' );
|
|||
// }
|
||||
// add_filter( 'mce_buttons_3', 'biofriction_mce_buttons_3' );
|
||||
|
||||
/**
|
||||
*
|
||||
* Custom settings page
|
||||
* * * * * * * * * * * * * * * * * * /
|
||||
*
|
||||
* @internal never define functions inside callbacks.
|
||||
* these functions could be run multiple times; this would result in a fatal error.
|
||||
* https://developer.wordpress.org/plugins/settings/custom-settings-page/
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Custom settings page
|
||||
* * * * * * * * * * * * * * * * * * /
|
||||
*
|
||||
* @internal never define functions inside callbacks.
|
||||
* these functions could be run multiple times; this would result in a fatal error.
|
||||
* https://developer.wordpress.org/plugins/settings/custom-settings-page/
|
||||
*/
|
||||
|
||||
/**
|
||||
* custom option and settings
|
||||
*/
|
||||
/**
|
||||
* custom option and settings
|
||||
*/
|
||||
function bfr_settings_init() {
|
||||
// register a new setting for "bfr" page
|
||||
register_setting( 'bfr_settings', 'bfr_options' );
|
||||
|
@ -205,14 +187,14 @@ function bfr_settings_init() {
|
|||
|
||||
|
||||
/**
|
||||
* register our bfr_settings_init to the admin_init action hook
|
||||
*/
|
||||
* register our bfr_settings_init to the admin_init action hook
|
||||
*/
|
||||
add_action( 'admin_init', 'bfr_settings_init' );
|
||||
|
||||
/**
|
||||
* custom option and settings:
|
||||
* callback functions
|
||||
*/
|
||||
* custom option and settings:
|
||||
* callback functions
|
||||
*/
|
||||
|
||||
// olderthandate section cb
|
||||
|
||||
|
@ -251,10 +233,10 @@ function bfr_field_olderthandate_cb( $args ) {
|
|||
<form id="bfr-oldpost-enddate" class="bfr-oldpost-enddate">
|
||||
<label for="bfr-oldpost-enddate">Start date:</label>
|
||||
<input type="date" id="bfr-oldpost-enddate" name="bfr-oldpost-endate" value="">
|
||||
</form>
|
||||
</form>
|
||||
|
||||
<!-- borrar desde aqui -->
|
||||
<p>
|
||||
<!-- borrar desde aqui -->
|
||||
<p>
|
||||
label_for:<?php echo esc_attr( $args['label_for'] ); ?>
|
||||
<br />
|
||||
bfr_custom_data:<?php echo esc_attr( $args['bfr_custom_data'] ); ?>
|
||||
|
@ -264,17 +246,17 @@ function bfr_field_olderthandate_cb( $args ) {
|
|||
<?php esc_html_e( 'daysback', 'bfr_plugin_txtdomain' ); ?>
|
||||
<br />
|
||||
|
||||
</p>
|
||||
</p>
|
||||
<!-- borrar hasta aqui -->
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* top level menu
|
||||
* https://developer.wordpress.org/reference/functions/add_menu_page/
|
||||
*/
|
||||
function bfr_options_page() {
|
||||
* top level menu
|
||||
* https://developer.wordpress.org/reference/functions/add_menu_page/
|
||||
*/
|
||||
function bfr_options_page() {
|
||||
// add top level menu page
|
||||
add_menu_page(
|
||||
$page_title = 'Biofriction Options', // $page_title
|
||||
|
@ -285,17 +267,11 @@ function bfr_field_olderthandate_cb( $args ) {
|
|||
$icon_url = 'dashicons-rest-api',// $icon_url //https://developer.wordpress.org/resource/dashicons/#menu
|
||||
$position = '50'// $position
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* register our bfr_options_page to the admin_menu action hook
|
||||
*/
|
||||
}
|
||||
// register our bfr_options_page to the admin_menu action hook
|
||||
add_action( 'admin_menu', 'bfr_options_page' );
|
||||
|
||||
/**
|
||||
* top level menu:
|
||||
* callback functions
|
||||
*/
|
||||
// top level menu: callback functions
|
||||
function bfr_options_page_html() {
|
||||
// check user capabilities
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
|
@ -335,3 +311,6 @@ function bfr_options_page_html() {
|
|||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Randomize images in gallery homepage
|
||||
// https://plugins.trac.wordpress.org/browser/random-gallery/trunk/random-gallery.php
|
||||
|
|
Loading…
Reference in New Issue