Modificare testo della pagina di protezione
-
Ciao a tutti,
stavo provando a modificare il testo standard che appare quando proteggi una pagina con la password. Il testo in questione è: "This post is password protected. To view it please enter your password below:".
Ho provato ad aggiungere al file "functions.php" i seguenti codici:
function my_password_form() { global $post; $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID ); $o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> ' . __( "To view this protected post, enter the password below:" ) . ' <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" /> </form> '; return $o; } add_filter( 'the_password_form', 'my_password_form' );E anche questo:
function custom_password_form_text( $text ) { $text = str_replace( 'This content is password protected. To view it please enter your password below:', 'your text', $text ); return $text; } add_filter( 'the_password_form', 'custom_password_form_text' );Ma nessuno dei due funziona. Qualcuno conosce un altro metodo per modificare la scritta?
PS: sto usando la versione 4.4.2 di Wordpress
-
-
Probabilmente se ne esce con qeusta action al posto di quelle due:
// Password Protected Page Message function custom_password_form($form) { $subs = array( '#<p>Il tuo testo abc: Il tuo testo abc</p>#' => '<p>Il tuo testo abc Il tuo testo abc Il tuo testo abc.</p>', '#<form(.*?)>#' => '<form$1 class="passwordform">', '#<input(.*?)type="password"(.*?) />#' => '<input$1type="password"$2 class="text" />', '#<input(.*?)type="submit"(.*?) />#' => '<input$1type="submit"$2 class="button" />' ); echo preg_replace(array_keys($subs), array_values($subs), $form); } add_filter('the_password_form', 'custom_password_form');non testato, magari aiuta.
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi