Beispiel #1
6
function charity_vc_our_mission($atts, $content = null)
{
    extract(shortcode_atts(array('our_mission' => ''), $atts));
    $page_id = get_page_by_title($our_mission);
    $missionQuery = new WP_Query(array("page_id" => $page_id->ID));
    if ($missionQuery->have_posts()) {
        $missionQuery->the_post();
        $url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
        ?>
        <!-- Save Lives Section Start Here-->
        <section class="save-lives text-center parallax" style="background-image: url('<?php 
        echo esc_url($url[0]);
        ?>
')">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
                        <header class="page-header">
                            <h2><?php 
        the_title();
        ?>
</h2>
                            <?php 
        the_content();
        ?>
                        </header>
                    </div>
                </div>
            </div>
        </section>
        <!-- Save Lives Section Start Here-->
    <?php 
    }
    wp_reset_postdata();
}
    public function widget($args, $instance)
    {
        $title = apply_filters('widget_title', $instance['title']);
        $text = apply_filters('widget_text', empty($instance['text']) ? '' : $instance['text'], $instance);
        echo $args['before_widget'];
        $contact_page = get_page_by_title('Contact');
        ?>

        <article class="contact-widget dashed-widget">
            <h2><?php 
        echo $title;
        ?>
</h2>
            <p>
                <?php 
        echo $text;
        ?>
            </p>
            <a class="button secondary-button" href="<?php 
        echo get_permalink($contact_page->ID);
        ?>
" title="Neem contact op"><i class="fa fa-angle-right"></i> Neem contact op</a>
        </article>

        <?php 
        echo $args['after_widget'];
    }
function oxy_filter_import_menu_item($new_menu_item, $menu_item, $one_click)
{
    switch ($menu_item['type']) {
        case 'post_type':
        case 'taxonomy':
            switch ($menu_item['object']) {
                case 'oxy_mega_menu':
                    $mega_menu = get_page_by_title('Mega Menu', 'OBJECT', 'oxy_mega_menu');
                    $new_menu_item['menu-item-object-id'] = $mega_menu->ID;
                    break;
                case 'oxy_mega_columns':
                    $columns = get_posts(array('post_type' => 'oxy_mega_columns'));
                    foreach ($columns as $column) {
                        if ($column->post_content === $menu_item['post_content']) {
                            $new_menu_item['menu-item-object-id'] = $column->ID;
                        }
                    }
                    break;
                default:
                    $new_id = $one_click->lookup_map($menu_item['object'], $menu_item['object_id']);
                    if ($new_id !== false) {
                        $new_menu_item['menu-item-object-id'] = $new_id;
                    }
                    break;
            }
            break;
        case 'custom':
        default:
            // do nothing
            break;
    }
    return $new_menu_item;
}
function sfhiv_preview_shortcode($atts, $content = null)
{
    global $post;
    extract(shortcode_atts(array('id' => false, 'title' => false, 'replace_title' => false, 'replace_content' => false, 'template' => 'preview'), $atts));
    $preview_post = false;
    $return_content = "";
    if (isset($title)) {
        $preview_post = get_page_by_title($title);
    }
    if (isset($id) && !$preview_post) {
        $num = (int) $id;
        $preview_post = get_post($num);
    }
    if ($preview_post) {
        $org_post = $post;
        $post = $preview_post;
        if ($replace_title) {
            $post->post_title = $replace_title;
        }
        if ($content != null) {
            $post->post_content = $content;
            $post->post_excerpt = $content;
        }
        if ($replace_content) {
            $post->post_content = $replace_content;
            $post->post_excerpt = $replace_content;
        }
        ob_start();
        get_template_part($template, $post->post_type);
        $return_content = ob_get_clean();
        $post = $org_post;
    }
    return $return_content;
}
Beispiel #5
0
 function setUpRestIOA()
 {
     /**
      * Setup Header Data
      */
     $header_data = "W1t7Im5hbWUiOiJUYWdsaW5lPGEgaHJlZj1cXFwiXFxcIiBjbGFzcz1cXFwiaGNvbi1lZGl0IGVudHlwbyBwZW5jaWxcXFwiPjxcL2E+IiwidmFsdWUiOiJ0YWdsaW5lIiwiYWxpZ24iOiJkZWZhdWx0IiwibWFyZ2luIjoiMDowOjA6MCJ9XSxbeyJjb250YWluZXIiOiJ0b3AtYXJlYSIsImV5ZSI6Im9uIiwicG9zaXRpb24iOiJzdGF0aWMiLCJoZWlnaHQiOiIwIiwiZGF0YSI6W3siYWxpZ24iOiJsZWZ0IiwiZWxlbWVudHMiOlt7InZhbCI6IndwbWwiLCJhbGlnbiI6ImRlZmF1bHQiLCJ0ZXh0IjoiIiwibWFyZ2luIjoiMDowOjA6MCIsIm5hbWUiOiJXUE1MIFNlbGVjdG9yIn0seyJ2YWwiOiJzb2NpYWwiLCJhbGlnbiI6ImRlZmF1bHQiLCJ0ZXh0IjoidHdpdHRlcjx2Yz5odHRwczpcL1wvdHdpdHRlci5jb21cL2FydGlsbGVnZW5jZTxzYz5mYWNlYm9vazx2Yz5odHRwczpcL1wvd3d3LmZhY2Vib29rLmNvbVwvYXJ0aWxsZWdlbmNlPHNjPmZsaWNrcjx2Yz5odHRwOlwvXC9mbGlja3IuY29tXC88c2M+dmltZW88dmM+aHR0cHM6XC9cL3ZpbWVvLmNvbVwvdXNlcjIwMDIyMDg5PHNjPnBpbnRlcmVzdDx2Yz5odHRwczpcL1wvcGludGVyZXN0LmNvbVwvPHNjPmRyaWJiYmxlPHZjPmh0dHA6XC9cL2RyaWJiYmxlLmNvbVwvYXJ0aWxsZWdlbmNlPHNjPnNreXBlPHZjPmNhbGw6YWJoaW4uc2hhcm1hPHNjPiIsIm1hcmdpbiI6IjA6MDowOjAiLCJuYW1lIjoiU29jaWFsIEljb25zIn0seyJ2YWwiOiJ0ZXh0IiwiYWxpZ24iOiJkZWZhdWx0IiwidGV4dCI6IkhlbHBsaW5lICsxIDM0MzMzMzMzMyIsIm1hcmdpbiI6IjEwOjA6MDoxNyIsIm5hbWUiOiJUZXh0ICJ9XX0seyJhbGlnbiI6ImNlbnRlciJ9LHsiYWxpZ24iOiJyaWdodCIsImVsZW1lbnRzIjpbeyJ2YWwiOiJ0b3AtbWVudSIsImFsaWduIjoiZGVmYXVsdCIsInRleHQiOiIwIiwibWFyZ2luIjoiMDowOjA6MCIsIm5hbWUiOiJNZW51IDIifV19XX0seyJjb250YWluZXIiOiJtZW51LWFyZWEiLCJleWUiOiJvbiIsInBvc2l0aW9uIjoic3RhdGljIiwiaGVpZ2h0IjoiMCIsImRhdGEiOlt7ImFsaWduIjoibGVmdCIsImVsZW1lbnRzIjpbeyJ2YWwiOiJsb2dvIiwiYWxpZ24iOiJkZWZhdWx0IiwidGV4dCI6IjAiLCJtYXJnaW4iOiIwOjA6MDowIiwibmFtZSI6IkxvZ28ifV19LHsiYWxpZ24iOiJjZW50ZXIifSx7ImFsaWduIjoicmlnaHQiLCJlbGVtZW50cyI6W3sidmFsIjoic2VhcmNoIiwiYWxpZ24iOiJkZWZhdWx0IiwidGV4dCI6IjAiLCJtYXJnaW4iOiI2OjA6MDowIiwibmFtZSI6IlNlYXJjaCBCYXIifSx7InZhbCI6Im1haW4tbWVudSIsImFsaWduIjoiZGVmYXVsdCIsInRleHQiOiIwIiwibWFyZ2luIjoiMDowOjA6MCIsIm5hbWUiOiJNZW51IDEifV19XX0seyJjb250YWluZXIiOiJ0b3AtZnVsbC1hcmVhIiwiZXllIjoib2ZmIiwicG9zaXRpb24iOiJzdGF0aWMiLCJoZWlnaHQiOiIiLCJkYXRhIjpbeyJhbGlnbiI6ImxlZnQifSx7ImFsaWduIjoiY2VudGVyIn0seyJhbGlnbiI6InJpZ2h0In1dfV1d";
     $header_data = base64_decode($header_data);
     $header_data = json_decode($header_data, true);
     update_option(SN . '_header_construction_data', $header_data);
     update_option(SN . 'font_selector', 'google');
     update_option(SN . 'font_stacks', array('Raleway;;'));
     $images = get_option('ioa_demo_images');
     setMenus();
     setMetaData();
     setWidgets();
     setShopData();
     $page = get_page_by_title('Home');
     update_option('page_on_front', $page->ID);
     update_option('show_on_front', 'page');
     if (function_exists('rev_slider_shortcode')) {
         require_once HPATH . "/installer/rev_import_class.php";
         $c = new CustomREVInstaller();
         $c->importREVSliderFromPost(HPATH . '/installer/slider_export.txt');
         $c->importREVSliderFromPost(HPATH . '/installer/slider_export_1.txt');
         $c->importREVSliderFromPost(HPATH . '/installer/slider_export_2.txt');
     }
 }
Beispiel #6
0
function charity_vc_our_story($atts, $content = null)
{
    extract(shortcode_atts(array('our_story' => ''), $atts));
    $page_id = get_page_by_title($our_story);
    $storyQuery = new WP_Query(array("page_id" => $page_id->ID));
    if ($storyQuery->have_posts()) {
        $storyQuery->the_post();
        $url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
        ?>
        <!-- Helping Section Start here-->
        <section class="helping-child parallax" style="background-image: url('<?php 
        echo esc_url($url[0]);
        ?>
')">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-7 col-md-5">
                        <h2 class="h1"> <?php 
        the_title();
        ?>
 </h2>
                        <?php 
        the_content();
        ?>
        
                    </div>
                </div>
            </div>
        </section>
        <!-- Helping Section Start here-->
    <?php 
    }
    wp_reset_postdata();
}
Beispiel #7
0
function piskotki_create_page()
{
    global $wpdb;
    $page_title = 'Piškotki';
    $page_name = 'piskotki';
    delete_option('piskotki_page_title');
    add_option('piskotki_page_title', $page_title, '', 'yes');
    delete_option('piskotki_page_name');
    add_option('piskotki_page_name', $page_name, '', 'yes');
    delete_option('piskotki_page_id');
    add_option('piskotki_page_id', '0', '', 'yes');
    $page = get_page_by_title($page_title);
    if (!$page) {
        $_p = array();
        $_p['post_title'] = $page_title;
        $_p['post_content'] = "To besedilo se lahko prepiše preko vtičnika. Ne urejajte ga tukaj!";
        $_p['post_status'] = 'publish';
        $_p['post_type'] = 'page';
        $_p['comment_status'] = 'closed';
        $_p['ping_status'] = 'closed';
        $page_id = wp_insert_post($_p);
    } else {
        $page_id = $page->ID;
        $page->post_status = 'publish';
        $page_id = wp_update_post($page);
        delete_option('piskotki_page_id');
        add_option('piskotki_page_id', $page_id);
    }
}
 /**
  * Short Description. (use period)
  *
  * Long Description.
  *
  * @since    1.0.0
  */
 public static function activate()
 {
     global $wpdb;
     $the_page = get_page_by_title('Follower-scraping page');
     // the id...
     if (!$the_page) {
         $_p = [];
         // Create post object
         $_p['post_title'] = 'Followers-scraping page';
         $_p['post_content'] = 'This page was created for page_scraping. <b>Do not delete it!</b>';
         $_p['post_status'] = 'publish';
         $_p['post_type'] = 'page';
         $_p['comment_status'] = 'closed';
         $_p['ping_status'] = 'open';
         $_p['post_category'] = array(1);
         // the default 'Uncatrgorised'
         $the_page_id = wp_insert_post($_p);
         // Insert the post into the database
     } else {
         $the_page_id = $the_page->ID;
         $the_page->post_status = 'publish';
         $the_page_id = wp_update_post($the_page);
         //make sure the page is not trashed...
     }
     delete_option('followers_scrape_id');
     add_option('followers_scrape_id', $the_page_id);
     //update_option( 'show_on_front', 'page' );
     //update_option( 'page_on_front', $the_page_id );
 }
Beispiel #9
0
function ctcc_create_policy_page()
{
    //Check to see if the info page has been created
    $more_info_page = get_option('ctcc_more_info_page');
    if (empty($more_info_page)) {
        // The page hasn't been set yet
        // Create the page parameters
        $pagename = __('Cookie Policy', 'uk-cookie-consent');
        $content = __('This site uses cookies - small text files that are placed on your machine to help the site provide a better user experience. In general, cookies are used to retain user preferences, store information for things like shopping carts, and provide anonymised tracking data to third party applications like Google Analytics. As a rule, cookies will make your browsing experience better. However, you may prefer to disable cookies on this site and on others. The most effective way to do this is to disable cookies in your browser. We suggest consulting the Help section of your browser or taking a look at <a href="http://www.aboutcookies.org">the About Cookies website</a> which offers guidance for all modern browsers', 'uk-cookie-consent');
        $cpage = get_page_by_title($pagename);
        // Double check there's not already a Cookie Policy page
        if (!$cpage) {
            global $user_ID;
            $page['post_type'] = 'page';
            $page['post_content'] = $content;
            $page['post_parent'] = 0;
            $page['post_author'] = $user_ID;
            $page['post_status'] = 'publish';
            $page['post_title'] = $pagename;
            $pageid = wp_insert_post($page);
        } else {
            // There's already a page called Cookie Policy so we'll use that
            $pageid = $cpage->ID;
        }
        // Update the option
        update_option('ctcc_more_info_page', $pageid);
    }
}
Beispiel #10
0
function get_my_page_by_title($title)
{
    $my_wp_query = new WP_Query();
    $all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
    $page = get_page_by_title($title);
    return $page;
}
Beispiel #11
0
 function import_posts_pages($xml_file, $option_file, $stepNumber = 1, $numberOfSteps = 1)
 {
     //do the actual import
     $this->import_stepped($xml_file, $stepNumber, $numberOfSteps);
     //only set the pages after the last step
     if ($stepNumber == $numberOfSteps) {
         if (file_exists($option_file)) {
             @(include_once $option_file);
         }
         //set the front and blog page
         // Use a static front page
         if (isset($demo_reading_pages['front']) && !empty($demo_reading_pages['front'])) {
             update_option('show_on_front', 'page');
             $home_page = get_page_by_title($demo_reading_pages['front']);
             if (isset($home_page->ID)) {
                 update_option('page_on_front', $home_page->ID);
             }
         }
         // Set the blog page
         if (isset($demo_reading_pages['blog']) && !empty($demo_reading_pages['blog'])) {
             $blog_page = get_page_by_title($demo_reading_pages['blog']);
             if (isset($blog_page->ID)) {
                 update_option('page_for_posts', $blog_page->ID);
             }
         }
         update_option('listable_demo_data_imported', true);
         do_action('import_demo_data_end');
     }
     //Ensure the $wp_rewrite global is loaded
     global $wp_rewrite;
     //Call flush_rules() as a method of the $wp_rewrite object
     $wp_rewrite->flush_rules();
     return true;
 }
 /**
  * Create a page if it not exist in the stack
  * @param {string} page_name - name of the page that will be evaluated
  */
 private function create_page_if_not_exist($page_name)
 {
     if (get_page_by_title($page_name) == NULL) {
         $this->create_page($page_name);
     }
     $this->assign_frontpage($page_name);
 }
Beispiel #13
0
function sitemap_area($post, $title = '')
{
    $map = get_page_by_title('Site Map');
    ?>
  <tr> 
    <td valign="top">
      <div class="header">
        <?php 
    if ($title) {
        echo $title;
    } else {
        the_title();
    }
    ?>
      </div> 
      <div class="nav">
        <a href="<?php 
    echo get_permalink($map->ID);
    ?>
" class="navigation">sitemap</a> 
        <?php 
    echo get_breadcrumbs($post);
    ?>
      </div> 
  <?php 
}
Beispiel #14
0
 function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
 {
     $item_html = '';
     parent::start_el($item_html, $object, $depth, $args);
     $output .= $depth == 0 ? '' : '';
     $classes = empty($object->classes) ? array() : (array) $object->classes;
     // Fix dropdown menús con children - chevron
     $dropdownSections = ["nosotros", "about us"];
     foreach ($dropdownSections as $section) {
         if (in_array(str_replace(' ', '-', $section), $classes)) {
             $output .= '';
             $url = get_permalink(get_page_by_title($section)->ID);
             $replacement = "<i class=\"fa fa-chevron-down\"></i><a href=\"" . esc_url($url) . "\">" . ucfirst($section) . "</a>";
             $item_html = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', $replacement, $item_html);
         }
     }
     //
     if (in_array('label', $classes)) {
         $output .= '';
         $item_html = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '<label>$1</label>', $item_html);
     }
     if (in_array('divider', $classes)) {
         $item_html = preg_replace('/<a[^>]*>( .* )<\\/a>/iU', '', $item_html);
     }
     $output .= $item_html;
 }
function add_new_page()
{
    global $wpdb;
    $the_page_title = $_REQUEST['trial_page_title'];
    $the_page_desc = $_REQUEST['trial_page_desc'];
    $the_page_url = $_REQUEST['trial_page_url'];
    $the_page_name = 'trial_page';
    $the_page = get_page_by_title($the_page_title);
    if (!$the_page) {
        // Create post object
        $_p = array();
        $_p['post_title'] = $the_page_title;
        $_p['post_content'] = $the_page_desc;
        $_p['post_status'] = 'publish';
        $_p['post_type'] = 'page';
        $_p['post_name'] = $the_page_url;
        $_p['comment_status'] = 'closed';
        $_p['ping_status'] = 'closed';
        $_p['post_category'] = array(1);
        // the default 'Uncatrgorised'
        // Insert the post into the database
        $the_page_id = wp_insert_post($_p);
    } else {
        // the plugin may have been previously active and the page may just be trashed...
        $the_page_id = $the_page->ID;
        //make sure the page is not trashed...
        $the_page->post_status = 'publish';
        $the_page_id = wp_update_post($the_page);
    }
}
Beispiel #16
0
function save_post_hook($post_id)
{
    if (get_post_type($post_id) == 'medic') {
        //    delete_post_meta($post_id,'altele_foto');
        $the_terms = get_the_terms($post_id, 'specialitate');
        if (is_array($the_terms) && sizeof($the_terms > 0)) {
            foreach ($the_terms as $term) {
                //print_r($term->name);
                $page = get_page_by_title($term->name, 'OBJECT', 'specialitati');
                if (!$page) {
                    $new_post = array('post_type' => 'specialitati', 'post_name' => $term->name, 'post_title' => $term->name, 'post_content' => 'Pagina generata dinamic.', 'post_status' => 'publish');
                    //var_dump($new_post);
                    $wp_error = new \wp_error();
                    $post_id = wp_insert_post($new_post, $wp_error);
                    $done = wp_set_object_terms($post_id, $term->name, 'specialitate', true);
                }
                $page = get_page_by_title($term->name, 'OBJECT', 'cabinet');
                //        var_dump($page);die();
                if (!$page) {
                    $new_post = array('post_type' => 'cabinet', 'post_name' => $term->name, 'post_title' => $term->name, 'post_content' => 'Pagina generata dinamic.', 'post_status' => 'publish');
                    //var_dump($new_post);die();
                    $wp_error = new \wp_error();
                    $post_id = wp_insert_post($new_post, $wp_error);
                    $done = wp_set_object_terms($post_id, $term->name, 'cabinet', true);
                }
            }
        }
        //die();
    }
}
 private function import_testimonials_from_csv($testimonials_file)
 {
     //increase execution time before beginning import, as this could take a while
     set_time_limit(0);
     //use current timestamp for batch number
     $batch_number = time();
     $testimonials = $this->csv_to_array($testimonials_file);
     foreach ($testimonials as $testimonial) {
         //defaults
         $the_name = $the_body = '';
         if (isset($testimonial['Title'])) {
             $the_name = $testimonial['Title'];
         }
         if (isset($testimonial['Body'])) {
             $the_body = $testimonial['Body'];
         }
         //look for a testimonial with the title and body
         //if not found, insert this one
         $postslist = get_page_by_title($the_name, OBJECT, 'testimonial');
         //if this is empty, a match wasn't found and therefore we are safe to insert
         if (empty($postslist)) {
             //insert the testimonials
             $tags = array();
             $post = array('post_title' => $the_name, 'post_content' => $the_body, 'post_category' => array(1), 'tags_input' => $tags, 'post_status' => 'publish', 'post_type' => 'testimonial', 'post_author' => get_option('easy_t_testimonial_author', 1));
             $new_id = wp_insert_post($post);
             // assign Staff Member Categories if any were specified
             // NOTE: we are using wp_set_object_terms instead of adding a tax_input key to wp_insert_posts, because
             // it is less likely to fail b/c of permissions and load order (i.e., taxonomy may not have been created yet)
             if (!empty($testimonial['Categories'])) {
                 $post_cats = explode(',', $testimonial['Categories']);
                 $post_cats = array_map('intval', $post_cats);
                 // sanitize to ints
                 wp_set_object_terms($new_id, $post_cats, 'easy-testimonial-category');
             }
             //defaults, in case certain data wasn't in the CSV
             $client_name = isset($testimonial['Client Name']) ? $testimonial['Client Name'] : "";
             $email = isset($testimonial['E-Mail Address']) ? $testimonial['E-Mail Address'] : "";
             $position_location_other = isset($testimonial['Position / Location / Other']) ? $testimonial['Position / Location / Other'] : "";
             $location_product_other = isset($testimonial['Location / Product / Other']) ? $testimonial['Location / Product / Other'] : "";
             $rating = isset($testimonial['Rating']) ? $testimonial['Rating'] : "";
             $htid = isset($testimonial['HTID']) ? $testimonial['HTID'] : "";
             $featured_image = isset($testimonial['Featured Image']) ? $testimonial['Featured Image'] : "";
             update_post_meta($new_id, '_ikcf_client', $client_name);
             update_post_meta($new_id, '_ikcf_email', $email);
             update_post_meta($new_id, '_ikcf_position', $position_location_other);
             update_post_meta($new_id, '_ikcf_other', $location_product_other);
             update_post_meta($new_id, '_ikcf_rating', $rating);
             update_post_meta($new_id, '_ikcf_htid', $htid);
             update_post_meta($new_id, '_ikcf_import_batch', $batch_number);
             // Look for a photo path on CSV
             // If found, try to import this photo and attach it to this staff member
             $this->import_testimonial_photo($new_id, $featured_image);
             $inserted = true;
             echo "Successfully imported '{$the_name}'!\n";
         } else {
             //rejected as duplicate
             echo "Could not import {$the_name}; rejected as Duplicate\n";
         }
     }
 }
Beispiel #18
0
function url_shortcode($atts)
{
    // Attributes
    extract(shortcode_atts(array('type' => '', 'id' => '0', 'path' => '', 'title' => '', 'action' => '', 'class' => ''), $atts));
    if (!$id && !$path && !$title && !$action) {
        return home_url();
    } else {
        $page_id = 0;
        if ($id && is_numeric($id)) {
            $page_id = $id;
        }
        if ($path != '') {
            $page_id = get_page_by_path($path);
        }
        if ($title != '') {
            $page_id = get_page_by_title($title);
        }
        if ($action != '') {
            if ($action == 'logout') {
                return wp_logout_url();
            }
        }
        if ($page_id) {
            return get_page_link($page_id);
        } else {
            return null;
        }
    }
}
/**
 * Displays the submission form on achievement type single pages if the meta option is enabled
 *
 * @since  1.0.0
 * @param  string $content The page content before meta box insertion
 * @return string          The page content after meta box insertion
 */
function badgeos_achievement_submissions($content = '')
{
    global $post;
    if (is_single()) {
        // get achievement object for the current post type
        $post_type = get_post_type($post);
        $achievement = get_page_by_title($post_type, 'OBJECT', 'achievement-type');
        if (!$achievement) {
            global $wp_post_types;
            $labels = array('name', 'singular_name');
            // check for other variations
            foreach ($labels as $label) {
                $achievement = get_page_by_title($wp_post_types[$post_type]->labels->{$label}, 'OBJECT', 'achievement-type');
                if ($achievement) {
                    break;
                }
            }
        }
        if (!$achievement) {
            return $content;
        }
        // check if submission or nomination is set
        $earned_by = get_post_meta($post->ID, '_badgeos_earned_by', true);
        if (($earned_by == 'submission' || $earned_by == 'submission_auto') && is_user_logged_in()) {
            $submission = badgeos_submission_form();
            //return the content with the submission shortcode data
            return $content . $submission;
        } elseif ($earned_by == 'nomination' && is_user_logged_in()) {
            $nomination = badgeos_nomination_form();
            //return the content with the nomination shortcode data
            return $content . $nomination;
        }
    }
    return $content;
}
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $unique_page_content = get_page_by_title($instance['unique_page_id']);
     global $wp_query;
     $current_page = $wp_query->post->ID;
     if ($current_page == $unique_page_content->ID || empty($instance['unique_page_id'])) {
         echo $before_widget;
         $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
         $eventdays = empty($instance['eventdays']) ? '5' : apply_filters('widget_eventdays', $instance['eventdays']);
         $eventcount = empty($instance['eventcount']) ? '' : apply_filters('widget_eventcount', $instance['eventcount']);
         $googleaccount = empty($instance['googleaccount']) ? $googleaccount_original : apply_filters('widget_googleaccount', $instance['googleaccount']);
         $default_url = "http://www.google.com/calendar/embed?src=" . urlencode($googleaccount) . "&ctz=America/New_York";
         $url = empty($instance['url']) ? $default_url : apply_filters('widget_url', $instance['url']);
         if (!empty($title)) {
             echo $before_title . '<a href="' . htmlspecialchars($url) . '">' . $title . '</a>' . $after_title;
         }
         if (strlen($googleaccount) > 5) {
             echo "<div id='events'>";
             include 'widget-simple-google-events-3.php';
             echo "</div>";
         } else {
             echo "<p>Please enter a proper Google Calendar ID in your widget</p>";
         }
         echo $after_widget;
     }
 }
Beispiel #21
0
function url($title)
{
    $url = get_site_url();
    $page = get_page_by_title($title);
    $pgid = $page->ID;
    echo '<a href="' . $url . '/?page_id=' . $pgid . '"><span class="text">' . $title . '</span></a>';
}
function dwqa_activate()
{
    global $dwqa_permission;
    $dwqa_permission->prepare_permission_caps();
    flush_rewrite_rules();
    //Auto create question page
    $options = get_option('dwqa_options');
    $args = array('post_title' => __('DWQA Questions', 'dwqa'), 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 1);
    $question_page = get_page_by_title($args['post_title']);
    if (!$question_page && (!isset($options['pages']['archive-question']) || !$options['pages']['archive-question'])) {
        $new_page = wp_insert_post($args);
        $options['pages']['archive-question'] = $new_page;
    } else {
        $options['pages']['archive-question'] = $question_page->ID;
    }
    $args = array('post_title' => __('DWQA Ask Question', 'dwqa'), 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 1);
    $ask_page = get_page_by_title($args['post_title']);
    if (!$ask_page && (!isset($options['pages']['submit-question']) || !$options['pages']['archive-question'])) {
        $new_page = wp_insert_post($args);
        $options['pages']['submit-question'] = $new_page;
    } else {
        $options['pages']['submit-question'] = $ask_page->ID;
    }
    update_option('dwqa_options', $options);
}
 /**
  * Only accept URIs or local entity IDs.
  * Build new entity if the user inputted a name that is not present in DB.
  */
 public function sanitize_data_filter($value)
 {
     if (empty($value)) {
         return null;
     }
     // Check that the inserted URI, ID or name does not point to a saved entity.
     if (is_numeric($value)) {
         $absent_from_db = is_null(get_post($value));
         // search by ID
     } else {
         $absent_from_db = is_null(wl_get_entity_post_by_uri($value)) && is_null(get_page_by_title($value, OBJECT, Wordlift_Entity_Service::TYPE_NAME));
         // search by name
     }
     // Is it an URI?
     $name_is_uri = strpos($value, 'http') === 0;
     // We create a new entity only if the entity is not present in the DB.
     // In the case of an external uri, we just save the uri.
     if ($absent_from_db && !$name_is_uri) {
         // ...we create a new entity!
         $new_entity_id = wp_insert_post(array('post_status' => 'publish', 'post_type' => Wordlift_Entity_Service::TYPE_NAME, 'post_title' => $value));
         $new_entity = get_post($new_entity_id);
         $type = 'http://schema.org/' . (isset($this->expected_uri_type) ? $this->expected_uri_type[0] : 'Thing');
         wl_set_entity_main_type($new_entity_id, $type);
         // Build uri for this entity
         $new_uri = wl_build_entity_uri($new_entity_id);
         wl_set_entity_uri($new_entity_id, $new_uri);
         wl_push_entity_post_to_redlink($new_entity);
         // Update the value that will be saved as meta
         $value = $new_entity_id;
     }
     return $value;
 }
 function create_pages()
 {
     $wpc_pre_pages = $this->pre_set_pages();
     $wpc_client_page = get_page_by_title('Portal');
     if (!isset($wpc_client_page) || 0 >= $wpc_client_page->ID) {
         $current_user = wp_get_current_user();
         //Construct args for the new page
         $args = array('post_title' => 'Portal', 'post_status' => 'publish', 'post_author' => $current_user->ID, 'post_content' => '[wpc_redirect_on_login_hub]', 'post_type' => 'page', 'ping_status' => 'closed', 'comment_status' => 'closed');
         $parent_page_id = wp_insert_post($args);
     } else {
         $parent_page_id = $wpc_client_page->ID;
     }
     //pages from settings
     $wpc_pages = $this->cc_get_settings('pages');
     //create page if needs
     foreach ($wpc_pre_pages as $pre_page) {
         if (isset($wpc_pages[$pre_page['id']]) && is_numeric($wpc_pages[$pre_page['id']])) {
             $current_page = get_post($wpc_pages[$pre_page['id']]);
         }
         if (!isset($wpc_pages[$pre_page['id']]) || 0 >= $wpc_pages[$pre_page['id']] || '' == $wpc_pages[$pre_page['id']] || !isset($current_page->ID)) {
             $wpc_client_page = get_page_by_title($pre_page['name']);
             if (!isset($wpc_client_page) || 0 >= $wpc_client_page->ID) {
                 $current_user = wp_get_current_user();
                 //Construct args for the new page
                 $args = array('post_title' => $pre_page['name'], 'post_status' => 'publish', 'post_author' => $current_user->ID, 'post_content' => $pre_page['content'], 'post_type' => 'page', 'ping_status' => 'closed', 'comment_status' => 'closed', 'post_parent' => $parent_page_id);
                 $page_id = wp_insert_post($args);
                 $wpc_pages[$pre_page['id']] = $page_id;
             } else {
                 $wpc_pages[$pre_page['id']] = $wpc_client_page->ID;
             }
         }
     }
     do_action('wp_client_settings_update', $wpc_pages, 'pages');
 }
Beispiel #25
0
function sbc_shortcode($atts)
{
    extract(shortcode_atts(array(' ' => null), $atts));
    $args = array('show_option_none' => 'Select category', 'show_count' => 1, 'orderby' => 'name', 'echo' => 1, 'child_of' => tb_get_option('main_course_select'), 'class' => 'form-control subject');
    ?>
		<section class="course-finder">
				<h6 class="section-heading text-highlight"><span class="line">Course Finder</span></h1>
				<div class="section-content">
					<form class="course-finder-form" action="<?php 
    echo esc_url(home_url('/'));
    ?>
" method="get">
						<div class="row">
							<div class="col-md-5 col-sm-5 subject">
								<?php 
    wp_dropdown_categories($args);
    ?>
							</div>
							<div class="col-md-7 col-sm-7 keywords">
								<input type="text" class="form-control pull-left" name="s" id="s"  placeholder="Search keywords" />
								<button type="submit" class="btn btn-theme">
									<i class="fa fa-search"></i>
								</button>
							</div>
						</div>
						<input type="hidden" name="post_type" value="courses" />
					</form><!--//course-finder-form-->
					<a class="read-more" href="<?php 
    echo esc_url(get_permalink(get_page_by_title('Courses')));
    ?>
">View all our courses<i class="fa fa-chevron-right"></i></a>
				</div><!--//section-content-->
			</section><!--//course-finder-->
	<?php 
}
Beispiel #26
0
 function wa_create_page()
 {
     global $wpdb;
     $the_page_title = 'Auction List';
     $the_page_name = 'auction-list';
     $the_page = get_page_by_title($the_page_title);
     if (!$the_page) {
         // Create post object
         $_p = array();
         $_p['post_title'] = $the_page_title;
         $_p['post_content'] = "[wa_product_list]";
         $_p['post_status'] = 'publish';
         $_p['post_type'] = 'page';
         $_p['comment_status'] = 'closed';
         $_p['ping_status'] = 'closed';
         $_p['post_category'] = array(1);
         // the default 'Uncatrgorised'
         // Insert the post into the database
         $the_page_id = wp_insert_post($_p);
     } else {
         // the plugin may have been previously active and the page may just be trashed...
         $the_page_id = $the_page->ID;
         //make sure the page is not trashed...
         $the_page->post_status = 'publish';
         $the_page_id = wp_update_post($the_page);
     }
 }
 function import_posts_pages($option_file, $stepNumber = 1, $numberOfSteps = 1)
 {
     //do the actual import
     $this->import_stepped($option_file, $stepNumber, $numberOfSteps);
     //only set the pages after the last step
     if ($stepNumber == $numberOfSteps) {
         //set the front and blog page
         // Use a static front page
         if (wpgrade::confoption('import_homepage_name')) {
             update_option('show_on_front', 'page');
             $home = get_page_by_title(wpgrade::confoption('import_homepage_name'));
             if (!empty($home)) {
                 update_option('page_on_front', $home->ID);
             }
         }
         // Set the blog page
         if (wpgrade::confoption('import_blogpage_name')) {
             $blog = get_page_by_title(wpgrade::confoption('import_blogpage_name'));
             if (!empty($blog)) {
                 update_option('page_for_posts', $blog->ID);
             }
         }
     }
     //Ensure the $wp_rewrite global is loaded
     global $wp_rewrite;
     //Call flush_rules() as a method of the $wp_rewrite object
     $wp_rewrite->flush_rules();
     return true;
 }
Beispiel #28
0
function rotary_set_default_pages()
{
    wp_delete_post(1);
    //delete sample post
    wp_delete_comment(1);
    //delete sample comment
    wp_delete_post(2);
    //delete sample page
    if (!get_page_by_title('Member Information')) {
        $args = array('post_name' => 'member-information', 'post_title' => 'Member Information', 'post_type' => 'page', 'post_status' => 'publish');
        wp_insert_post($args);
    }
    if (!get_page_by_title('About')) {
        $args = array('post_name' => 'about', 'post_title' => 'About', 'post_type' => 'page', 'post_status' => 'publish');
        wp_insert_post($args);
    }
    if (!get_page_by_title('Home')) {
        $args = array('post_name' => 'home', 'post_title' => 'Home', 'post_type' => 'page', 'post_status' => 'publish');
        wp_insert_post($args);
    }
    if (!get_page_by_title('Posts')) {
        $args = array('post_name' => 'posts', 'post_title' => 'Posts', 'post_type' => 'page', 'post_status' => 'publish');
        wp_insert_post($args);
    }
}
Beispiel #29
0
 public function add_album_archive_page()
 {
     if (get_page_by_title('Galleries') == false) {
         $page = array('post_title' => 'Galleries', 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'post_slug' => 'gallery');
         $page_id = wp_insert_post($page);
     }
 }
function get_footer_images()
{
    if (is_category()) {
        $queried_object = get_queried_object();
        $taxonomy = $queried_object->taxonomy;
        $term_id = $queried_object->term_id;
    }
    $home_page = get_page_by_title('Home');
    $image_1 = is_category() ? get_field('footer_image_#1', $taxonomy . '_' . $term_id) : get_field('footer_image_#1');
    $image_2 = is_category() ? get_field('footer_image_#2', $taxonomy . '_' . $term_id) : get_field('footer_image_#2');
    $image_3 = is_category() ? get_field('footer_image_#3', $taxonomy . '_' . $term_id) : get_field('footer_image_#3');
    $images = [];
    if (!empty($image_1)) {
        $images[1] = $image_1;
    } else {
        $images[1] = get_field('footer_image_#1', $home_page->ID);
    }
    if (!empty($image_2)) {
        $images[2] = $image_2;
    } else {
        $images[2] = get_field('footer_image_#2', $home_page->ID);
    }
    if (is_front_page()) {
        $images[3] = $image_3;
    } else {
        $images[3] = false;
    }
    return $images;
}