in order to disable google translate for post content, you might use the following script in your functions.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
function my_body_classes( $classes ) { $post_id = get_the_ID(); if (get_post_type($post_id) != 'post') { return $classes; } $value = get_post_meta($post_id, '_my_custom_field', true); if( $value == 1){ $classes[] = 'notranslate'; $classes[] = 'ahmad1'; } return $classes; } add_filter( 'post_class','my_body_classes' ); add_action('post_submitbox_misc_actions', createCustomField); add_action('save_post', saveCustomField); function createCustomField() { $post_id = get_the_ID(); if (get_post_type($post_id) != 'post') { return; } $value = get_post_meta($post_id, '_my_custom_field', true); wp_nonce_field('my_custom_nonce_'.$post_id, 'my_custom_nonce'); ?> <div class="misc-pub-section misc-pub-section-last"> <label><input type="checkbox" value="1" <?php checked($value, true, true); ?> name="_my_custom_field" /><?php _e('Disable google translate', 'pmg'); ?></label> </div> <?php } function saveCustomField($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if ( !isset($_POST['my_custom_nonce']) || !wp_verify_nonce($_POST['my_custom_nonce'], 'my_custom_nonce_'.$post_id) ) { return; } if (!current_user_can('edit_post', $post_id)) { return; } if (isset($_POST['_my_custom_field'])) { update_post_meta($post_id, '_my_custom_field', $_POST['_my_custom_field']); } else { delete_post_meta($post_id, '_my_custom_field'); } } |