Compare commits

..

5 Commits

6 changed files with 200 additions and 198 deletions

View File

@ -80,7 +80,7 @@ if( ! function_exists( 'xarxaprod_ajuts_filters_form') ) {
<?php }; //end foreach groupkey field ?>
<?php //echo '<p><span id="filterlink"></span></p>';?>
<p><a id="submitfilteredlink" name="submit-ajut" class="button button-more" href="">enviar</a> </p>
<p><a id="submitfilteredlink" name="submit-ajut" class="button button-more" href="">filtrar</a> </p>
</form>
<?php //close the form and subit ?>

View File

@ -80,7 +80,7 @@ if( ! function_exists( 'xarxaprod_associats_filters_form') ) {
<?php }; //end foreach groupkey field ?>
<?php //echo '<p><span id="filterlink"></span></p>';?>
<p><a id="submitfilteredlink" name="submit-associat" class="button button-more" href="">enviar</a> </p>
<p><a id="submitfilteredlink" name="submit-associat" class="button button-more" href="">filtrar</a> </p>
</form>
<?php //close the form and subit ?>

View File

@ -80,7 +80,7 @@ if( ! function_exists( 'xarxaprod_convos_filters_form') ) {
<?php }; //end foreach groupkey field ?>
<?php //echo '<p><span id="filterlink"></span></p>';?>
<p><a id="submitfilteredlink" name="submit-convo" class="button button-more" href="">enviar</a> </p>
<p><a id="submitfilteredlink" name="submit-convo" class="button button-more" href="">filtrar</a> </p>
</form>
<?php //close the form and subit ?>

View File

@ -19,227 +19,157 @@
/**
* custom option and settings
*/
if( ! function_exists('xarxaprod_wpplugin_settings_init') ){
function xarxaprod_wpplugin_settings_init() {
// register a new setting for "xarxaprod_wpplugin" page
register_setting( 'xarxaprod_wpplugin_settings', 'xarxaprod_wpplugin_options' );
* @internal never define functions inside callbacks.
* these functions could be run multiple times; this would result in a fatal error.
*/
// register a new section in the "xarxaprod_wpplugin" page
/**
* custom option and settings
*/
function xarxaprod_plugin_settings_init() {
// Register a new setting for "xxpplugin" page.
register_setting( 'xxpplugin', 'xarxaprod_plugin_options' );
// Register a new section in the "xxpplugin" page.
add_settings_section(
'xarxaprod_wpplugin_section_control_home',
__( 'Home control.', 'xarxaprod-wpplugin-textdomain' ),
'xarxaprod_wpplugin_section_control_home_cb',
'xarxaprod_wpplugin_settings'
'xarxaprod_plugin_section_options',
__( 'Control de les opcions de la web Xarxaprod', 'xxpplugin' ), 'xarxaprod_plugin_section_options_callback',
'xxpplugin'
);
// register a new field in the "xarxaprod_wpplugin_section_control_home" section, inside the "xarxaprod_wpplugin" page
//
// uncoment below to activate
// add_settings_field(
// 'xarxaprod_wpplugin_field_control_home', // as of WP 4.6 this value is used only internally
// // use $args' label_for to populate the id inside the callback
// __( 'This is the content being shown in home page:', 'xarxaprod-wpplugin-textdomain' ),
// 'xarxaprod_wpplugin_field_control_home_cb',
// 'xarxaprod_wpplugin_settings',
// 'xarxaprod_wpplugin_section_control_home'
// );
// register a new section in the "xarxaprod_wpplugin" page
add_settings_section(
'xarxaprod_wpplugin_section_reusableblocks',
__( 'Reusable blocks.', 'xarxaprod-wpplugin-textdomain' ),
'xarxaprod_wpplugin_section_reusableblocks_cb',
'xarxaprod_wpplugin_reusableblocks'
);
// register a new field in the "xarxaprod_wpplugin_section_reusableblocks" section, inside the "xarxaprod_wpplugin" page
//
// uncoment below to activate
// Register a new field in the "xarxaprod_plugin_section_options" section, inside the "xxpplugin" page.
add_settings_field(
'xarxaprod_wpplugin_field_reusableblocks', // as of WP 4.6 this value is used only internally
// use $args' label_for to populate the id inside the callback
__( 'Follow this link to edit the reusable blocks <a href="' . admin_url() . 'edit.php?post_type=wp_block" class="but.ton"> Reusable blocks</a>', 'xarxaprod-wpplugin-textdomain' ),
'xarxaprod_wpplugin_field_reusableblocks_cb',
'xarxaprod_wpplugin_settings',
'xarxaprod_wpplugin_section_reusableblocks',
// edit.php?post_type=wp_block
'xarxaprod_plugin_field_reusableblocks', // As of WP 4.6 this value is used only internally.
// Use $args' label_for to populate the id inside the callback.
__( 'Reusable blocks', 'xxpplugin' ),
'xarxaprod_plugin_field_reusableblocks_cb',
'xxpplugin',
'xarxaprod_plugin_section_options',
array(
'label_for' => 'xarxaprod_plugin_field_reusableblocks',
'class' => 'xarxaprod_plugin_row',
'xarxaprod_plugin_custom_data' => 'custom',
)
);
// register a new section in the "xarxaprod_wpplugin" page
//
// uncoment below to activate
// add_settings_section(
// 'xarxaprod_wpplugin_section_olderthandate',
// __( 'Older than options.', 'xarxaprod-wpplugin-textdomain' ),
// 'xarxaprod_wpplugin_section_olderthandate_cb',
// 'xarxaprod_wpplugin_settings'
// );
// register a new field in the "xarxaprod_wpplugin_section_olderthandate" section, inside the "xarxaprod_wpplugin" page
//
// uncoment below to activate
// add_settings_field(
// 'xarxaprod_wpplugin_field_olderthandate', // as of WP 4.6 this value is used only internally
// // use $args' label_for to populate the id inside the callback
// __( 'Hide content older than...', 'xarxaprod-wpplugin-textdomain' ),
// 'xarxaprod_wpplugin_field_olderthandate_cb',
// 'xarxaprod_wpplugin_settings',
// 'xarxaprod_wpplugin_section_olderthandate',
// [
// 'label_for' => 'xarxaprod_wpplugin_field_olderthandate',
// 'class' => 'xarxaprod-wpplugin-row',
// 'xarxaprod_wpplugin_custom_data' => 'custom',
// ]
// );
}
}
/**
* Register our xarxaprod_plugin_settings_init to the admin_init action hook.
*/
add_action( 'admin_init', 'xarxaprod_plugin_settings_init' );
/**
* register our xarxaprod_wpplugin_settings_init to the admin_init action hook
*/
add_action( 'admin_init', 'xarxaprod_wpplugin_settings_init' );
* Custom option and settings:
* - callback functions
*/
/**
* custom option and settings:
* callback functions
*/
// olderthandate section cb
// section callbacks can accept an $args parameter, which is an array.
// $args have the following keys defined: title, id, callback.
// the values are defined at the add_settings_section() function.
if( ! function_exists('xarxaprod_wpplugin_section_olderthandate_cb') ){
function xarxaprod_wpplugin_section_olderthandate_cb( $args ) {
* Xarxaprod section callback function.
*
* @param array $args The settings array, defining title, id, callback.
*/
function xarxaprod_plugin_section_options_callback( $args ) {
?>
<p id="<?php echo esc_attr( $args['id'] ); ?>">
<?php esc_html_e( 'Here you should set the options for the older content to be marked as it.', 'xarxaprod-wpplugin-textdomain' ); ?>
<p id="<?php echo esc_attr( $args['id'] ); ?>"><?php esc_html_e( 'Aquestes son las opcions de la pagina Xarxaprod 2023. Pots modificar i pots seguir els links dels botons.', 'xxpplugin' ); ?></p>
<?php
}
/**
* Reusable Blocks field callbakc function.
*
* WordPress has magic interaction with the following keys: label_for, class.
* - the "label_for" key value is used for the "for" attribute of the <label>.
* - the "class" key value is used for the "class" attribute of the <tr> containing the field.
* Note: you can add custom key value pairs to be used inside your callbacks.
*
* @param array $args
*/
function xarxaprod_plugin_field_reusableblocks_cb( $args ) {
// Get the value of the setting we've registered with register_setting()
$options = get_option( 'xarxaprod_plugin_options' );
?>
<p class="">
<a href="<?php echo admin_url(); ?>edit.php?post_type=wp_block" class="button">Reusable Blocks</a>
<?php esc_html_e( 'Si vols modificar els blocks reutilizables (els de color violeta) de las págines i entrades, fes click al botó.', 'xxpplugin' ); ?>
</p>
<?php
}
}
// daysback field cb
// field callbacks can accept an $args parameter, which is an array.
// $args is defined at the add_settings_field() function.
// wordpress has magic interaction with the following keys: label_for, class.
// the "label_for" key value is used for the "for" attribute of the <label>.
// the "class" key value is used for the "class" attribute of the <tr> containing the field.
// you can add custom key value pairs to be used inside your callbacks.
if( ! function_exists('xarxaprod_wpplugin_field_olderthandate_cb') ){
function xarxaprod_wpplugin_field_olderthandate_cb( $args ) {
// get the value of the setting we've registered with register_setting()
$options = get_option( 'xarxaprod_wpplugin_options' );
// output the field
?>
<p class="description">
<?php _e( 'You should set up the <b>number of days</b> from today to the past or the date from wich will be <b>considered old posts</b>. Then the class <span style="font-family:monospace;">oldpost</span> will be added to the post and pages so you can apply a css style to your theme.', 'xarxaprod-wpplugin-textdomain' ); ?>
</p>
<form id="xarxaprod_wpplugin-oldpost-numberofdays" class="xarxaprod_wpplugin-oldpost-numberofdays">
<label for="xarxaprod_wpplugin-oldpost-numberofdays">Number of days:</label>
<input type="number" id="xarxaprod_wpplugin-oldpost-numberofdays" name="xarxaprod_wpplugin-oldpost-numberofdays" min="1" max="100">
</form>
<form id="xarxaprod_wpplugin-oldpost-enddate" class="xarxaprod_wpplugin-oldpost-enddate">
<label for="xarxaprod_wpplugin-oldpost-enddate">Start date:</label>
<input type="date" id="xarxaprod_wpplugin-oldpost-enddate" name="xarxaprod_wpplugin-oldpost-endate" value="">
</form>
<!-- borrar desde aqui -->
<!--
<p>
label_for:
<?php //echo esc_attr( $args['label_for'] ); ?>
<br />
xarxaprod_wpplugin_custom_data:
<?php //echo esc_attr( $args['xarxaprod_wpplugin_custom_data'] ); ?>
<br />
class:
<?php //echo esc_attr( $args['class'] ); ?>
<br />
<?php //esc_html_e( 'daysback', 'xarxaprod-wpplugin-textdomain' ); ?>
<br />
</p>
-->
<!-- borrar hasta aqui -->
<?php
}
}
/**
* Lite Youtube Embed field callbakc function.
* https://wordpress.org/plugins/lite-embed-for-youtube
* https://github.com/paulirish/lite-youtube-embed
*
* WordPress has magic interaction with the following keys: label_for, class.
* - the "label_for" key value is used for the "for" attribute of the <label>.
* - the "class" key value is used for the "class" attribute of the <tr> containing the field.
* Note: you can add custom key value pairs to be used inside your callbacks.
*
* @param array $args
*/
/**
* top level menu
* https://developer.wordpress.org/reference/functions/add_menu_page/
*/
if( ! function_exists('xarxaprod_wpplugin_options_page') ){
function xarxaprod_wpplugin_options_page() {
if( ! function_exists('xarxaprod_plugin_options_page') ){
function xarxaprod_plugin_options_page() {
// add top level menu page
add_menu_page(
$page_title = 'Xarxaprod plugin options', // $page_title
$menu_title = 'Xarxaprod options', //$menu_title
$menu_title = 'Xarxaprod', //$menu_title
$capability = 'manage_options', //'edit_others_posts', // $capability
$menu_slug = 'xarxaprod-options', // $menu_slug
$function = 'xarxaprod_wpplugin_options_page_html', //$function
$icon_url = 'dashicons-rest-api',// $icon_url //https://developer.wordpress.org/resource/dashicons/#menu
$menu_slug = 'xxpplugin-options', // $menu_slug
$function = 'xarxaprod_plugin_options_page_html', //$function
$icon_url = 'dashicons-sos',// $icon_url //https://developer.wordpress.org/resource/dashicons/#menu
$position = '25'// $position
);
}
}
// register our xarxaprod_wpplugin_options_page to the admin_menu action hook
add_action( 'admin_menu', 'xarxaprod_wpplugin_options_page' );
// top level menu: callback functions
if( ! function_exists('xarxaprod_wpplugin_options_page_html') ){
function xarxaprod_wpplugin_options_page_html() {
/**
* Register our xarxaprod_plugin_options_page to the admin_menu action hook.
*/
add_action( 'admin_menu', 'xarxaprod_plugin_options_page' );
/**
* Top level menu callback function
*/
function xarxaprod_plugin_options_page_html() {
// check user capabilities
if ( ! current_user_can( 'manage_options' ) ) {
?>
<p class="description">
<?php esc_html_e( 'Sorry, you do not have permission to edit this settings, please, contact any admin to get granted.', 'xarxaprod-wpplugin-textdomain' ); ?>
</p>
<?php
return;
}
// add error/update messages
// check if the user have submitted the settings
// wordpress will add the "settings-updated" $_GET parameter to the url
// WordPress will add the "settings-updated" $_GET parameter to the url
if ( isset( $_GET['settings-updated'] ) ) {
// add settings saved message with the class of "updated"
add_settings_error( 'xarxaprod_wpplugin_messages', 'xarxaprod_wpplugin_message', __( 'Settings Saved', 'xarxaprod-wpplugin-textdomain' ), 'updated' );
add_settings_error( 'xarxaprod_plugin_messages', 'xarxaprod_plugin_message', __( 'Settings Saved', 'xxpplugin' ), 'updated' );
}
// show error/update messages
settings_errors( 'xarxaprod_wpplugin_messages' );
settings_errors( 'xarxaprod_plugin_messages' );
?>
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<form action="options.php" method="post">
<?php
// output security fields for the registered setting "xarxaprod_wpplugin"
settings_fields( 'xarxaprod_wpplugin_settings' );
// output security fields for the registered setting "xxpplugin"
settings_fields( 'xxpplugin' );
// output setting sections and their fields
// (sections are registered for "xarxaprod_wpplugin", each field is registered to a specific section)
do_settings_sections( 'xarxaprod_wpplugin_settings' );
// (sections are registered for "xxpplugin", each field is registered to a specific section)
do_settings_sections( 'xxpplugin' );
// output save settings button
submit_button( 'Save Settings' );
//submit_button( 'Save Settings' );
?>
</form>
</div>
<?php
}
}

View File

@ -0,0 +1,69 @@
<?php
/**
*
* functions to displaying the map with all members
* depens on plugins: LeafletMaps, ACF fields
*
*
* @link https://xarxaprod.cat
* @since 1.0.0
* @package xarxaprod-wp-plugin
* @subpackage xarxaprod-wp-plugin/includes
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
*
*/
// Detect plugin. For use on Front End only.
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// check for plugin using plugin name
if ( ! is_plugin_active( 'leaflet-map/leaflet-map.php' ) ) {
// echo '<p class="warning">The plugin <a hfref="https://wordpress.org/plugins/leaflet-map/">LeafletMap</a> is needed to show this map</p>';
} else {
if (! function_exists( 'xarxaprod_show_leaflet_map' )) {
function xarxaprod_show_leaflet_map() {
// show the map
echo do_shortcode( '[leaflet-map fitbounds max_zoom="18" lat="41.3922" lng="2.1755" height="100%" width="100%" tileurl=https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png scrollwheel detect-retina]');
}
};
if ( ! is_plugin_active( 'acf-openstreetmap-field/index.php' ) ) {
echo '<p class="warning">The plugin <a hfref="https://wordpress.org/plugins/acf-openstreetmap-field/">ACF OpenStreetMap Field</a> is needed to show the points in the map</p>';
} else {
if (! function_exists( 'xarxaprod_show_leaflet_associat_blob' )) {
function xarxaprod_show_leaflet_associat_blob() {
// get the field values
// https://www.advancedcustomfields.com/resources/get_field/
// var_dump get_field('');
$args = get_field('xxp_associat_osm_map',false, false);
if ( count( $args['markers'] ) ) {
foreach ( $args['markers'] as $marker ) {
// define the fields for the blob
if ( get_field('xxp_associat_citymap') ){
// if city for map written use it
$associat_address = get_field('xxp_associat_citymap');
} else {
// else use the ACF OpenStreetMap nominatim value
$associat_address = $marker['label'];
};
$associat_name = esc_html( get_the_title() );
$associat_xxp_weblink = '<a href="'. get_the_permalink() . '">' . $associat_name . '</a>';
$associat_own_weblink = '<a href="' . get_field('xxp_associat_web') . '" class="">' . get_field('xxp_associat_web') . '</a>';
$associat_email = '<a href="mailto:' . get_field('xxp_associat_mail') . '" class="">' . get_field('xxp_associat_mail') . '</a>';
$associat_lat = $marker['lat'];
$associat_lng = $marker['lng'];
if( get_field('xxp_associat_colormap') ){ $associat_blobcolor = get_field('xxp_associat_colormap'); }else{ $associat_blobcolor = '#555'; };
echo do_shortcode( '
[leaflet-marker svg background="'. $associat_blobcolor . '" color="'. $associat_blobcolor . '" iconSize="22,22" iconClass="dashicons dashicons-info" opacity="0.6" title="' . $associat_name . '" lat=' . $associat_lat . ' lng=' . $associat_lng . ']'
. '<p>' . $associat_address . '</p>'
. '<h5><b>' . $associat_xxp_weblink . '</b></h5>'
. '<p>' . $associat_own_weblink . '</p>'
. '<p>' . $associat_email . '</p>'
. '[/leaflet-marker]'
); // end shortcode each marker
}; // end each marker
}; // end count all markers
};
}; //end function xarxaprod_show_leaflet_associat_blob
};//end ACF OpenStreetMap active
};

View File

@ -57,7 +57,7 @@ define( 'XARXAPROD_WPPLUGIN_URL', plugin_dir_url( __FILE__ ) ); //public
include( XARXAPROD_WPPLUGIN_PATH . 'includes/plugin-init-textdomain.php');
//include( XARXAPROD_WPPLUGIN_PATH . 'includes/plugin-settings-pannel.php');
include( XARXAPROD_WPPLUGIN_PATH . 'includes/plugin-settings-pannel.php');
include( XARXAPROD_WPPLUGIN_PATH . 'includes/enable-svg.php');
@ -84,3 +84,6 @@ include( XARXAPROD_WPPLUGIN_PATH . 'includes/custom-field-associats-filter-funct
// plugin js scripts
include( XARXAPROD_WPPLUGIN_PATH . 'includes/register-plugin-scripts.php');
// include leaflet map shortcodes
include( XARXAPROD_WPPLUGIN_PATH . 'includes/xarxaprod-leafletmap.php');