class Test{
private $infos;
function get_info() {
if ( isset($_REQUEST['my_info']) ) {
$infos = $_REQUEST['my_info'];
if (get_option('my_url')){
update_option('my_url', $infos);
}else{
add_option('my_url', $infos);
}
}
die();
}
function salcodes_year() {
echo plugin_dir_url(__FILE__) . 'src/my_test1.php';
require_once plugin_dir_url(__FILE__) . 'src/my_test1.php';
$my_crawler = new Test_one($infos);
return get_option('my_url');
}
function js2php_register(){
add_action( 'wp_ajax_crawler_info', array($this, 'get_info') );
add_action( 'wp_ajax_nopriv_crawler_info', array($this, 'get_info') );
add_shortcode( 'current_year', array($this, 'salcodes_year') );
}
}
$test = new Test;
$test->js2php_register();
Through my testing I found no matter how do I put these code, require_once plugin_dir_url(__FILE__) . 'src/my_test1.php';
& $my_crawler = new Test_one($infos);
, in the function of add_shortcode()
or add_action('wp_ajax_')
both are not work…
Does anyone help me, Please
Thanks
class Test{
private $infos;
function get_info() {
if ( isset($_REQUEST['my_info']) ) {
$this->infos = $_REQUEST['my_info'];
echo 'your input is:'.$this->infos;
}
// Always die in functions echoing ajax content or it will display 0 or another word
// die();
}
function salcodes_year() {
echo 'the data is:'.$this->var;
return $this->var;
}
function js2php_register(){
add_action( 'wp_ajax_test_info', array($this, 'get_info') );
add_action( 'wp_ajax_nopriv_test_info', array($this, 'get_info') );
add_shortcode( 'current_year', array($this, 'salcodes_year') );
}
}
$test = new Test;
$test->js2php_register();
Version:
WordPress 5.8.2
PHP 7.4.27
MySQL 5.7.37 Community Server (GPL)
Help me, please!
]]>Just example for one of default values.
My tag in Control Form 7:
<label> Requestor name
[dynamictext* RequestorName readonly “RequestorNameFromDB”] </label>
My code in functions.php
add_shortcode( ‘RequestorNameFromDB’, ‘funRequestorNameFromDB’ );
function funRequestorNameFromDB() {
$RequestorNameFromDB = ‘1namefromDB’;
return $RequestorNameFromDB;
}
Regards,
Miroslaw Kazmierczak
how to resolved problem.
i need help.
]]>I’m trying to output all the tags on a page, but for some reason it does not work.
Docs: get_tags and add_shortcode
Code for functions.php:
function get_all_tags($atts, $content = null ) {
$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}({$tag->count})</a>";
}
$html .= '</div>';
return $html;
}
add_shortcode('alltags', 'get_all_tags');
It looks simple, but for some reason I still miss something. Does someone have an idea or a hint for me?
Thanks a lot!
]]>Using add_shortcode will probably also increase the likelihood of continued support in future WP versions.
So is there any chance you’ll do it?
Using add_shortcode will probably also increase the likelihood of continued support in future WP versions.
So is there any chance you’ll do it?
I may have found the reason – the shortcodes that don’t work in MLA Text Widget don’t use add_shortcode but run directly on contents.
If you can confirm that’s the reason, I’ll ask them to fix this. But they haven’t updated their plugins for more than a year, so it may be a lost cause.
Plus who knows how many other plugins out there suffer from the same issue, so please find a way to run them anyway, just like WP runs them anyway.
Examples:
Works in MLA Text Widget and uses add_shortcode:
Doesn’t work in MLA Text Widget and doesn’t use add_shortcode:
<?php
function shortcode_hdid() {
return 'Hello world';
}
function add_ggc_shortcodes() {
add_shortcode('hdid','shortcode_hdid');
}
add_action('init', 'add_ggc_shortcodes', 99);
?>
… and in a page I insert [hdid] but Hello world does not appear when viewing the page.
This is driving me mad and any help would be most appreciated.
]]>