mutosfr
Forum Replies Created
-
Forum: Reviews
In reply to: [All-in-One WP Migration and Backup] Tested and approvedHi wechinee,
Even bought the extension plugin, worked like a breeze, so I’ll be able to prototype the site on a test installation, then replicate it when going live. And of course, being able to have backups at any time in case of mishap…
Forum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyOK, solved for me with the above changes !
Forum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyHi Anders,
Here’s my final code, including :
– A log function to allow debugging, plus my detailed debug lines,
– Use of variables to make S&R code more readable, debug-friendly and customizable,
– Customization of the 1st search’s $strSearch value according to my configuration./** * Send to debug.log if WP_DEBUG is defined and true * * @since 2.2.0 * * @param string $function Function name * @param int $line Line number * @param mixed $msg Message to output * @param mixed $debug Variable to print_r */ public static function log_if_debug( $function, $line, $msg, $debug = null ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( "In $function, $line:" . print_r( $msg, true ) . ( $debug ? print_r( $debug, true ) : '' ) ); } } //Rewrite links and image tags function rewrite ( $text, $mode='images' ) { //Log parameters when WP_DEBUG is set to True self::log_if_debug( __METHOD__, __LINE__, '==== BEGIN DEBUG ====' ); self::log_if_debug( __METHOD__, __LINE__, 'wikidir : '.$this->wikidir ); self::log_if_debug( __METHOD__, __LINE__, 'wikiurl : '.$this->wikiurl ); self::log_if_debug( __METHOD__, __LINE__, '======== Text before Replacements ========' ); self::log_if_debug( __METHOD__, __LINE__, $text ); //Rewrite links to other wiki pages $strSearch = '/'.$this->wikidir.'/index.php?title='; $strReplace = '?wikipage='; self::log_if_debug( __METHOD__, __LINE__, '======== 1st str_replace() ========' ); self::log_if_debug( __METHOD__, __LINE__, 'Search for : '.$strSearch ); self::log_if_debug( __METHOD__, __LINE__, 'Replace with : '.$strReplace ); $text = str_replace( $strSearch, $strReplace, $text ); self::log_if_debug( __METHOD__, __LINE__, 'Text after Replacement : ' ); self::log_if_debug( __METHOD__, __LINE__, $text ); //Rewrite other relative links $strSearch = '/'.$this->wikidir; $strReplace = $this->wikiurl; self::log_if_debug( __METHOD__, __LINE__, '======== 2nd str_replace() ========' ); self::log_if_debug( __METHOD__, __LINE__, 'Search for : '.$strSearch ); self::log_if_debug( __METHOD__, __LINE__, 'Replace with : '.$strReplace ); $text = str_replace( $strSearch, $strReplace, $text ); self::log_if_debug( __METHOD__, __LINE__, 'Text after Replacement : ' ); self::log_if_debug( __METHOD__, __LINE__, $text ); //Rewrite image if( $mode == 'images' ) { self::log_if_debug( __METHOD__, __LINE__, '======== Call to $this->rewrite_images() ========' ); $text = $this->rewrite_images( $text ); self::log_if_debug( __METHOD__, __LINE__, 'text after Replacement : ' ); self::log_if_debug( __METHOD__, __LINE__, $text ); } else { self::log_if_debug( __METHOD__, __LINE__, '======== No Image Replacement ========' ); } self::log_if_debug( __METHOD__, __LINE__, '==== END DEBUG ====' ); return $text; } //Load the page from the wiki and rewrite links function load_page( $page ) { $url=$this->wikiurl.'/api.php?action=parse&format=json&disableeditsection&redirects&page='.urlencode($page); curl_setopt($this->ch,CURLOPT_URL,$url); $json_raw=curl_exec($this->ch); $json=json_decode($json_raw,true); $json['parse']['text']['*']=$this->rewrite($json['parse']['text']['*']); return $json; }Forum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyHi Anders,
In fact, it actually worked, but it seems a combination of the Illdy theme and the WP_DEBUG prevented the page from displaying. With 2013 theme, I got the WP_DEBUG error messages, then the wiki data, and when I disable WP_DEBUG, all is well.
Forum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyHi Anders,
Should have seen that in the first place : my MW URLs are not in the same form as yours. It could be, that I use a very old MW, or a parameter (I’ll have to upgrade it anyway, but for now I’ll work around the issue temporarily).
Basically, your format is
index.php/PageNamewhen mine is
index.php?title=PageNameNow the URLs get rewritten, but they are not recognized by the page.
I get a rewritten URL in the form
http://test.hoshikaze.net/wordpress-5.0.2-fr_FR/presentation-de-lunivers/especes/?wikipage=PageNameForum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyHello Anders,
In fact, the ToC links were not rewritten because they were in the form href=”#Marker”, so that’s normal.
On the links that don’t get rewritten, I’m still in the dark…
Forum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyHi Anders,
I’ve modified the rewrite() function as follows to issue debug logs :
/** * Send to debug.log if WP_DEBUG is defined and true * * @since 2.2.0 * * @param string $function Function name * @param int $line Line number * @param mixed $msg Message to output * @param mixed $debug Variable to print_r */ public static function log_if_debug( $function, $line, $msg, $debug = null ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( "In $function, $line:" . print_r( $msg, true ) . ( $debug ? print_r( $debug, true ) : '' ) ); } } //Rewrite links and image tags function rewrite ( $text, $mode='images' ) { //Log parameters when WP_DEBUG is set to True self::log_if_debug( __METHOD__, __LINE__, 'wikidir : '.$this->wikidir ); self::log_if_debug( __METHOD__, __LINE__, 'wikiurl : '.$this->wikiurl ); self::log_if_debug( __METHOD__, __LINE__, 'text before : \n'.$text ); //Rewrite links to other wiki pages $text = str_replace( '/'.$this->wikidir.'/index.php/', '?wikipage=',$text ); self::log_if_debug( __METHOD__, __LINE__, 'text after 1 : \n'.$text ); //Rewrite other relative links $text = str_replace( '/'.$this->wikidir,$this->wikiurl, $text ); self::log_if_debug( __METHOD__, __LINE__, 'text after 2 : \n'.$text ); //Rewrite image if( $mode == 'images' ) { $text = $this->rewrite_images( $text ); self::log_if_debug( __METHOD__, __LINE__, 'text after images : \n'.$text ); } return $text; }Forum: Plugins
In reply to: [Wikiembedder] Link rewrite under WP 5.0.2 with theme IlldyHi Anders,
I’ve found a clue, but I still don’t understand.
The following Links :
http://hoshikaze.net/hk-wiki/index.php?title=Sshaad#Physique
http://hoshikaze.net/hk-wiki/index.php?title=Danebget rewritten to :
http://test.hoshikaze.net/wordpress-5.0.2-fr_FR/presentation-de-lunivers/especes/#Physique
http://hoshikaze.net/hk-wiki//index.php?title=DanebThe first one gets correctly rewritten, the second one is NOT rewritten…
It sure has something to do with the rewrite() function, and more precisely with the str_replace() parameters in line 88 of wikiembedder.php, but for now I don’t know how to print variables to a kind of debug log… I’ll look at that…