shortcode not working on back office page
-
Hello,
i’m using your plugin to print 1 page in my back office.
In the plugin code, i’ve added this :
<?php echo do_shortcode('[print-me]' ); ?>
When I check on my browser this element is created :
<div class="printomatic pom-default " id="id4167" alt="IMPRIMER LA PAGE" title="IMPRIMER LA PAGE" data-print_target=""></div>
But there is no JQuery event attached to this element, as it should be…
On the web page i’ve just the defaut title displayed and i can’t print.If i just add the shortcode on any other page (front end) it is working perfectly (with the jquery event).
Could you please help me with this issue ?
Thank you very much.
Guilhem
-
what is the default print target set in the plugin settings, and does that element exist on the page in question?
Also: what is a ‘backoffice page’?
Also: where exactly are you entering the
do_shortcode
php?- This reply was modified 5 years, 7 months ago by twinpictures.
the defaut print target is : #a_imprimer and yes this element exist on the page.
The page is an administration page that i’ve created for my client where he can view some usermetadata details.
I’m doing the do_shortcode in the page like this :
<?php /** * The plugin area to view the usermeta */ if( current_user_can('edit_users' ) ) { ?> <div id="a_imprimer"> <h2> <?php echo __('Détail sur la personne inscrite : ' . $inscrit . ' (' . $user->user_login . ')', $this->plugin_text_domain ); ?> </h2> <a href="<?php echo esc_url( add_query_arg( array( 'page' => wp_unslash( $_REQUEST['page'] ) ) , admin_url( 'users.php' ) ) ); ?>"><?php _e( 'Retour', $this->plugin_text_domain ) ?></a> <?php echo do_shortcode('[print-me target ="#a_imprimer"]' ); ?> <div class="details_inscrit"> <?php //$usermeta = get_user_meta( $user_id ); $bool_seul_resp=false; $bool_conjoint_resp=false; foreach( $array_infos as $key => $value ) { if($key == 'info_perso'){ echo '<div class="card">'; echo '<h2>Informations personnelles</h2>'; echo '<table style="width:100%"><tbody>'; foreach($value as $key_data => $data){ if($key_data == 'Date de naissance'){ $datatodisplay = get_user_meta($user_id, 'wpuef_cid_'.$data,true); $d = new DateTime($datatodisplay); $datatodisplay = $d->format('d/m/Y'); } else if ($key_data == 'Peut partir seul' || $key_data == 'Droit à l\'image'){ $datatodisplay = get_user_meta($user_id, 'wpuef_cid_'.$data,true); if($datatodisplay == 1){ $datatodisplay = 'Non'; } else { $datatodisplay = 'Oui'; } } else { $datatodisplay = get_user_meta($user_id, 'wpuef_cid_'.$data,true); } echo '<tr><td style="width:50%">'. $key_data . '</td><td style="width:50%">' . $datatodisplay. '</td></tr>'; } echo '</tbody></table>'; echo '</div><br>'; } if(isset($enfant)){ if($key == 'responsable_legal1'){ echo '<div class="card">'; echo '<h2>1er responsable légal</h2>'; echo '<table style="width:100%"><tbody>'; foreach($value as $key_data => $data){ echo '<tr><td style="width:50%">'. $key_data . '</td><td style="width:50%">' . get_user_meta( $user_id, 'wpuef_cid_'.$data,true). '</td></tr>'; } echo '</tbody></table>'; echo '</div><br>'; } //test si seul responsable if($key == 'responsables'){ foreach($value as $key_data => $data){ if($key_data=='seul_responsable'){ $seul_responsable=get_user_meta( $user_id, 'wpuef_cid_'.$data,true); } if($key_data=='conjoint_responsable'){ $conjoint_responsable=get_user_meta( $user_id, 'wpuef_cid_'.$data,true); } // var_dump($seul_responsable); // var_dump($conjoint_responsable); } if($seul_responsable==0){ $bool_seul_resp=true; }if($conjoint_responsable==0){ $bool_conjoint_resp=true; } } if($key == 'responsable_legal2'&&$bool_conjoint_resp&&!$bool_seul_resp){ echo '<div class="card">'; echo '<h2>Conjoint et 2ème responsable légal</h2>'; echo '<table style="width:100%"><tbody>'; foreach($value as $key_data => $data){ echo '<tr><td style="width:50%">'. $key_data . '</td><td style="width:50%">' . get_user_meta( $user_id, 'wpuef_cid_'.$data,true). '</td></tr>'; } echo '</tbody></table>'; echo '</div><br>'; }else if($key == 'responsable_legal2'&&!$bool_conjoint_resp&&!$bool_seul_resp){ echo '<div class="card">'; echo '<h2>Conjoint sans responsabilité légale</h2>'; echo '<table style="width:100%"><tbody>'; foreach($value as $key_data => $data){ echo '<tr><td style="width:50%">'. $key_data . '</td><td style="width:50%">' . get_user_meta( $user_id, 'wpuef_cid_'.$data,true). '</td></tr>'; } echo '</tbody></table>'; echo '</div><br>'; } if($key == 'responsable_legal3'&&!$bool_conjoint_resp&&!$bool_seul_resp){ if(!empty(get_user_meta( $user_id, 'wpuef_cid_'.$value['Nom - Prenom'],true))){ echo '<div class="card">'; echo '<h2>Responsable légal ne vivant pas au foyer</h2>'; echo '<table style="width:100%"><tbody>'; foreach($value as $key_data => $data){ echo '<tr><td style="width:50%">'. $key_data . '</td><td style="width:50%">' . get_user_meta( $user_id, 'wpuef_cid_'.$data,true). '</td></tr>'; } echo '</tbody></table>'; echo '</div><br>'; } } } if(isset($adulte)){ if($key == 'conjoint'){ echo '<div class="card">'; echo '<h2>Conjoint</h2>'; echo '<table style="width:100%"><tbody>'; foreach($value as $key_data => $data){ echo '<tr><td style="width:50%">'. $key_data . '</td><td style="width:50%">' . get_user_meta( $user_id, 'wpuef_cid_'.$data,true). '</td></tr>'; } echo '</tbody></table>'; echo '</div><br>'; } } if($key == 'personne_prev'){ echo '<div class="card">'; echo '<h2>Liste des personnes à contacter en cas d\'urgence</h2>'; $index = 1; $datatodisplay = ''; foreach($value as $data){ $datatodisplay = ''; if(!empty(get_user_meta( $user_id, 'wpuef_cid_'.$data['Nom - Prenom'],true))){ echo '<h2>Contact n° '.$index.'</h2>'; echo '<table style="width:100%"><tbody>'; foreach($data as $key_d => $d){ $datatodisplay = ''; if($key_d == 'Autorisations'){ $auto= get_user_meta( $user_id, 'wpuef_cid_'.$d,true); if($auto[0]){ $datatodisplay = 'A prévenir en cas d\'urgence'; } if(!empty($datatodisplay)){ $datatodisplay .= '<br>'; } if($auto[1]){ $datatodisplay .= 'Peut récupérer un enfant'; } } else { $datatodisplay = get_user_meta( $user_id, 'wpuef_cid_'.$d,true); } echo '<tr><td style="width:50%">'. $key_d . '</td><td style="width:50%">' .$datatodisplay . '</td></tr>'; } echo '</tbody></table>'; } $index++; } echo '</div><br>'; } } ?> <a href="<?php echo esc_url( add_query_arg( array( 'page' => wp_unslash( $_REQUEST['page'] ) ) , admin_url( 'users.php' ) ) ); ?>"><?php _e( 'Retour', $this->plugin_text_domain ) ?></a> <?php } else { ?> <p> <?php echo __( 'You are not authorized to perform this operation.', $this->plugin_text_domain ) ?> </p> <?php }?> </div> </div>
ok, so when you say:
The page is an administration page that i’ve created for my client where he can view some usermetadata details.
do you mean it’s in the admin area (dashboard/backend) or in the front end/public part of the wordpress site?
Please check out the latest release candidate on GitHub:
https://github.com/baden03/print-o-maticThis adds an option to include the plugin scripts on the admin dashboard.
Let us know if this resolves the issue for you.Thank you for your answer.
I’ve installed the latest version with the option to activate the script on admin dashboard.
Now I’ve the print icon with a link but when I click on it nothing happen.
When i inspect the element I can see that not even is attached…
Let me know if you need an access to this admin page and I will create a user profile for you.
Many thanks for your kind help.
GuilhemYeah, it might be best if you contact us direct so we can take a close look. write us at info [at] twinpictures [dot] de and be sure to include a link to this thread in the email. We’ll get a solution worked out for you.
Thank you very much.
I’ll do as suggested.
Kind regards,
Guilhem
- The topic ‘shortcode not working on back office page’ is closed to new replies.