Uncategorized

English

Important aspects of English grammar

Parts of Speech

  • nouns
  • pronouns
  • verbs
  • adjectives
  • adverbs
  • prepositions
  • conjunctions
  • interjections
  • subject
  • object

Sentence Structure

sentence types

  • declarative
  • interrogative
  • imperative
  • exclamatory

Tenses

  • present
  • past
  • future

Articles

  • a
  • an
  • the

Modifiers

Adjectives and adverbs are modifiers that provide additional information about nouns and verbs, respectively.

Prepositions

Prepositions show relationships between nouns or pronouns and other elements in a sentence. Understanding prepositions is important for describing location, time, and direction.

Conjunctions

Conjunctions connect words, phrases, or clauses in a sentence

Direct and Indirect Speech

Direct and indirect speech are two ways of conveying what someone has said

Direct Speech

Direct speech involves quoting the speaker’s exact words within quotation marks. It is used when you want to report someone’s speech word-for-word

Example: Sarah said, “I am going to the store.”

Indirect Speech

Indirect speech involves paraphrasing or reporting what someone said without quoting their exact words.

Example: Sarah said that she was going to the store.

In indirect speech present tense can become past tense, and past tense can become past perfect

  • Direct speech: Mary said, “I am tired.”
  • Indirect speech: Mary said that she was tired.
  • Direct speech: “I’ll be there,” he promised.
  • Indirect speech: He promised that he would be there.
  • Direct speech: “Are you coming?” she asked.
  • Indirect speech: She asked if/whether I was coming.
Interview Prepartion, Uncategorized

WordPress create custom frontend form

Add this code for save custom field value

function __update_post_meta( $post_id, $field_name, $value = '' )
{
    if ( empty( $value ) OR ! $value )
    {
        delete_post_meta( $post_id, $field_name );
    }
    elseif ( ! get_post_meta( $post_id, $field_name ) )
    {
        add_post_meta( $post_id, $field_name, $value );
    }
    else
    {
        update_post_meta( $post_id, $field_name, $value );
    }
}

add this code for html form

function newletterform(){
    if(isset($_POST['newslettersubmit']))
    {

        $id = wp_insert_post(array(
            'post_title'=>$_POST['newslettername'], 
            'post_type'=>'my_form',
          ));
          __update_post_meta( $id, 'customfield', $_POST['newsletteremail'] );
echo "<script>window.location.replace('".$_SERVER['HTTP_REFERER']."');</script>";
    }
    ?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>#newsletterform" class="row g-3" id="newsletterform">
								<div class="col-auto">
									<input type="text" class="form-control" placeholder="Enter your name" name="newslettername">
								</div>
								<div class="col-auto">
									<input type="email" class="form-control" placeholder="Enter your email" name="newsletteremail">
								</div>
								<div class="col-auto">
                                <input required type="hidden" name="page_options" value="newslettername, newsletteremail" />
									<input type="submit" class="btn btn-primary" name="newslettersubmit">
										<span class="fa fa-paper-plane"></span>
									</input>
								</div>
							</form>
    <?php
}

Register Post Type

$labels = array(
    'name'               => ucfirst('newsletter'),
    'singular_name'      => 'newsletter',
    'menu_name'          => ucfirst('newsletter'),
    'name_admin_bar'     => ucfirst('newsletter'),
    'add_new'            => 'Add New',
    'add_new_item'       => 'Add New '.ucfirst('newsletter').'',
    'new_item'           => 'New '.ucfirst('newsletter').'',
    'edit_item'          => 'Edit '.ucfirst('newsletter').'',
    'view_item'          => 'View '.ucfirst('newsletter').'',
    'all_items'          => 'All '.ucfirst('newsletter').'',
    'search_items'       => 'Search '.ucfirst('newsletter').'s',
    'parent_item_colon'  => 'Parent '.ucfirst('newsletter').':',
    'not_found'          => 'No '.'newsletter'.' found.',
    'not_found_in_trash' => 'No '.'newsletter'.'s found in Trash.'
);
$args = array( 
    'labels'		=> $labels,
    'public'		=> true,
    'rewrite'		=> array( 'slug' => 'newsletter' ),
    'has_archive'   => true,
    'show_in_menu' => false,
    'menu_position' => 20,
    'menu_icon'     => 'dashicons-carrot',
    'taxonomies'		=> array( 'post_tag', 'category' ),
    'supports'      => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt','custom-fields' )
);
register_post_type( 'newsletter', $args );

Frontend File upload code

/**********file upload code */
          require_once(ABSPATH . 'wp-admin/includes/file.php');
            global $wp_filesystem;
            WP_Filesystem();

            $content_directory = $wp_filesystem->wp_content_dir() . 'uploads/';
            $wp_filesystem->mkdir( $content_directory . 'newsletterfile' );

            $target_dir_location = $content_directory . 'newsletterfile/';

            if(isset($_FILES['newsletterfile'])){
                $name_file = 'newsletterfile'.date("h.iA").mt_rand(100000,999999).'.'.pathinfo($_FILES['newsletterfile']['name'],PATHINFO_EXTENSION);
                $tmp_name = $_FILES['newsletterfile']['tmp_name'];
            
                if( move_uploaded_file( $tmp_name, $target_dir_location.$name_file ) ) {
                    __update_post_meta( $id, 'newsletterfile', $name_file );
                } else {
                    //echo "The file was not uploaded";
                }
            }
            /***end file upload code */

Mail code

/***mail code */
            $to = 'ramkankannan@gmail.com'; //sendto@example.com
            $subject = 'Newsletter';
            $body = '<h1>'.$_POST['newslettername'].'</h1>';
            $body .= '<h1>'.$_POST['newsletteremail'].'</h1>';
            $headers = array('Content-Type: text/html; charset=UTF-8');
            
            wp_mail( $to, $subject, $body, $headers );
            /***end mail code */