stebcom
Forum Replies Created
-
Forum: Plugins
In reply to: [Fantastic ElasticSearch] Search won't display any resultsOk, I found that fuzzy search is triggered by appending “~” to the query string, hence the fuzziness amount parameters needs to be set at minimum value of 2.
This is not a good approach because no common user will append ~ to his query string without anyone telling him to. I edited the code, adding ~ to every query string, so that fuzzy search is always triggered.
I’ve just started exploring ElasticSearch and I don’t know it well, so this is probably not the best way to arrange things, but at least it’s working.Forum: Plugins
In reply to: [Fantastic ElasticSearch] Search won't display any resultsI noticed the plugin uses ruflin/Elastica php client, so I downloaded the latest version of that library, then searches started giving results (I’m using version 1.5.1 of ElasticSearch server, so I think server and php client versions simply didn’t match).
Not everything is ok though, because fuzzy searching is not working at all. Have you got any suggestion?
Forum: Plugins
In reply to: [WP Super Cache] Fatal error trying using dynamic contentI worked on this a lot of time ago, so I don’t remember that much. I think I gave up on Dynamic Cache Tag (the first option) because it didn’t work the way I needed, calling my functions ecc.
Speaking about the output buffer: the code is still quite simple. You can define your constant where you prefer, like this:define( 'DYNAMIC_OUTPUT_BUFFER_TAG', 'Your placeholder' );
The dynamic cache is not the only option to keep part of your pages dynamic, anyway: if you have issues with that, you should try loading your content via ajax.
Forum: Plugins
In reply to: [WP Super Cache] Fatal error trying using dynamic contentThis is an example of usage for a woocommerce cart widget.
I use this code in functions.php:if ( DYNAMIC_OUTPUT_BUFFER_TAG != '' ) { function dynamic_output_buffer_minicart( &$cachedata = 0 ) { if ( defined( 'DYNAMIC_OB_TEXT' ) ) return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata ); ob_start(); // call the sidebar function, do something dynamic woocommerce_mini_cart(); $text = ob_get_contents(); ob_end_clean(); if ( $cachedata === 0 ) { // called directly from the theme so store the output define( 'DYNAMIC_OB_TEXT', $text ); } else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata ); } function dynamic_output_buffer_init() { add_action( 'wp_footer', 'dynamic_output_buffer_minicart' ); //add_action( 'wp_footer', 'dynamic_output_buffer_sidebar' ); } function dynamic_output_buffer_test_safety( $safety ) { if ( defined( 'DYNAMIC_OB_TEXT' ) ) // this is set when you call dynamic_output_buffer_test() from the theme return 1; // ready to replace tag with dynamic content. else return 0; // tag cannot be replaced. } add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_minicart' ); add_cacheaction( 'add_cacheaction', 'dynamic_output_buffer_init' ); add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' ); }
And this code in my template page:
<?php if ( function_exists( 'dynamic_output_buffer_minicart' ) ) dynamic_output_buffer_minicart(); ?>Loading cart...
You should also enable late_init option in the WP Super Cache configuration.
Forum: Plugins
In reply to: [Events Made Easy] Event title not being displayedYes, the_title() has to be called from inside the loop, you’re right. I edited the code to make the function to be called this way, but it doesn’t work:I still get ‘Events’ as title.
The problem is that neither the wp_title() is working, so there must be something else I’m missing…Forum: Plugins
In reply to: [Events Made Easy] Event title not being displayedHi Franky, thank you for your answer. It’s somehow more complicated: I tried replacing the custom function of my theme with the standard “the_title()” call, but nothing changes. The only other difference between my custom theme and a standard one is that the title block is written in the header.php file, instead of the page.php.
Also, I cannot see the right title in the browser tab(<title> tag), even if it’s called the wp_title() function.Forum: Plugins
In reply to: [WP Super Cache] Trying to understand dynamic cacheaction filter…Ok, that didn’t work because there was no call to dynamic_output_buffer_test function in my template.
So, the correct code should be
function dynamic_output_buffer_test( &$cachedata = 0 ) { if ( defined( 'DYNAMIC_OB_TEXT' ) ) return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata ); ob_start(); // call the sidebar function, do something dynamic strtest(); $text = ob_get_contents(); ob_end_clean(); if ( $cachedata === 0 ) { // called directly from the theme so store the output define( 'DYNAMIC_OB_TEXT', $text ); } else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata ); } function dynamic_output_buffer_init() { add_action( 'wp_footer', 'dynamic_output_buffer_test' ); } function dynamic_output_buffer_test_safety( $safety ) { if ( defined( 'DYNAMIC_OB_TEXT' ) ) // this is set when you call dynamic_output_buffer_test() from the theme return 1; // ready to replace tag with dynamic content. else return 0; // tag cannot be replaced. } function strtest() { echo "hello"; } add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test' ); add_cacheaction( 'add_cacheaction', 'dynamic_output_buffer_init' ); add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
to use in functions.php, and
if ( function_exists( 'dynamic_output_buffer_test' ) ) strtest(); ?>MY_BUFFER_TAG
to use in my theme page.
Now, what if I need more than one section to stay dynamic? I would need to use more than a buffer, but how?
I adjusted the code, in order to output the different dynamic parts, when the function is called from my theme, but I get the same result in all positions. For example, if I want a mini cart widget and another sidebar to stay dynamic, I get two mini carts, the first in its own place, and the second replacing the other sidebar.Forum: Plugins
In reply to: [WP Super Cache] Trying to understand dynamic cacheaction filter…Ok,
I figured out how to make the dynamic cache work, using the simple replace method, but I can’t use the output buffer.
This is the code I put inside functions.php file of my theme
function dynamic_output_buffer_test( &$cachedata = 0 ) { if ( defined( 'DYNAMIC_OB_TEXT' ) ) return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata ); ob_start(); // call the sidebar function, do something dynamic strtest(); $text = ob_get_contents(); ob_end_clean(); if ( $cachedata === 0 ) { // called directly from the theme so store the output define( 'DYNAMIC_OB_TEXT', $text ); } else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata ); } function dynamic_output_buffer_init() { add_action( 'wp_footer', 'dynamic_output_buffer_test' ); } function dynamic_output_buffer_test_safety( $safety ) { if ( defined( 'DYNAMIC_OB_TEXT' ) ) // this is set when you call dynamic_output_buffer_test() from the theme return 1; // ready to replace tag with dynamic content. else return 0; // tag cannot be replaced. } function strtest() { echo "hello"; }
And this is what I put in my template
add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test' ); add_cacheaction( 'add_cacheaction', 'dynamic_output_buffer_init' ); add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' ); ?>MY_BUFFER_TAG
What am I doing wrong here?
Forum: Plugins
In reply to: [WP Super Cache] Fatal error trying using dynamic contentOk,
now I figured out how to make the dynamic cache work, but I have another problem now: I’m using the output buffer but it’s working only with Google Chrome, as the string replacement is not being performed with IE, nor Firefox. Unfortunately, I can’t spot any error and the cache logs the same lines after a page request made by Chrome and a page request made by Firefox or IE.
Any idea about this?
Forum: Plugins
In reply to: [WP Super Cache] Fatal error trying using dynamic contentI forgot to replace
add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
with
add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_test_safety' );
but I’m not able to get things working: I simply don’t see the code replacement.
Forum: Plugins
In reply to: [WP Super Cache] Trying to understand dynamic cacheaction filter…Hi,
I’m trying to implement the dynamic cache too, but I’m quite lost by now.
I got the dynamic-cache-test.php script, moved into a dynamic-cache-test folder under plugins folder and activated it as a new plugin.
I defined DYNAMIC_CACHE_TEST_TAG, then I edited a page from my theme, switching this code:<?php woocommerce_mini_cart(); ?>
with this:
<!--mydynamicdata--><br /> <?php woocommerce_mini_cart(); ?><br /> <!--/mydynamicdata-->
I expected to see the Hello World text replacing the cart, but I just see the string
–>
before and after the cart widget content.
If I just put my secret string in a template page, that string is removed, but replaced with nothing.
Can you point me to the correct using of the dynamic cache functionality?
Forum: Plugins
In reply to: [TablePress - Tables in WordPress made easy] Retrieve table IDFound it!
Thanks a lot!No, my problem is that I’ve just approached WordPress and I still have to learn how it works. Browsing the code, I found out that content.php is my actual template (for main contents), while page.php lies on a higher level. I’ll keep exploring that, thanks!
Ok, I managed to display blocks from Magento inserting the code (for example the_block(‘top.links’);) in my content.php page. Still, I don’t have any custom php code working when I put it in page.php.
Well, althought I have a bit of experience with Magento, I’m totally new to WordPress, so I think my problems are WordPress related.Thanks for the great job!