Example #1
0
function addpage($pagedef, $menu_id)
{
    $ret = null;
    $parent = $pagedef['parent'];
    $parentid = 0;
    $test = get_page_by_path($parent);
    if (!empty($test)) {
        $parentid = $test->ID;
    }
    // try to find if this page already exists
    $pid = getPageID($parent, $pagedef['url'], $pagedef['title']);
    // create the post
    $post = array();
    $post['ID'] = $pid;
    $post['menu_order'] = $pagedef['order'];
    $post['post_name'] = $pagedef['url'];
    if (empty($post['post_name'])) {
        $post['post_name'] = null;
    }
    $post['post_title'] = $pagedef['title'];
    $post['post_status'] = 'publish';
    $post['post_parent'] = $parentid;
    $post['comment_status'] = 'closed';
    // set the default content
    $content = $pagedef['content'];
    if ($content != '') {
        /* we check if the content is pointing to a local file */
        if (strpos($content, '/') === 0) {
            $cpath = get_local(plugins_url($content, __FILE__));
            $t = file_get_contents($cpath);
            $m = new Mustache_Engine();
            /* we need to call this function so the $bapi_all_options gets populated */
            bapi_wp_site_options();
            $wrapper = getbapisolutiondata();
            $string = $m->render($t, $wrapper);
        } else {
            /* if not is pointing to a json object */
            $jsonContent = file_get_contents($content);
            if ($jsonContent != FALSE) {
                $jsonObjContent = json_decode($jsonContent);
                $string = $jsonObjContent->result[0]->DocText;
            } else {
                $string = '';
            }
        }
        $string = str_replace("\t", '', $string);
        // remove tabs
        $string = str_replace("\n", '', $string);
        // remove new lines
        $string = str_replace("\r", '', $string);
        // remove carriage returns
        $post['post_content'] = $string;
        //utf8_encode($string);
    } else {
        $post['post_content'] = '';
    }
    $post['post_type'] = 'page';
    $action = "Added";
    if ($pid == 0) {
        $pid = wp_insert_post($post, $error);
    } else {
        $action = "Edited";
        wp_update_post($post);
    }
    add_post_meta($pid, 'bapi_page_id', $pagedef['intid'], true);
    update_post_meta($pid, "_wp_page_template", $pagedef['template']);
    $miid = 0;
    $addtomenu = $pagedef['addtomenu'] == 'true';
    if ($addtomenu && !doesNavMenuExist($pid)) {
        $miid = addtonav($pid, $menu_id, $post, $parent, $ret);
    }
    if ($post['post_title'] == 'Home') {
        update_option('page_on_front', $pid);
        update_option('show_on_front', 'page');
    }
    if ($post['post_title'] == 'Blog') {
        update_option('page_for_posts', $pid);
    }
    return array('action' => $action, 'post_title' => $post['post_title'], 'post_id' => $pid, 'miid' => $miid, 'menu_id' => $menu_id, 'add_to_nav' => $ret);
}
Example #2
0
    public function widget($args, $instance)
    {
        $wrapper = getbapisolutiondata();
        $logo = $wrapper["site"]["SolutionLogo"];
        $currdomain = $_SERVER['SERVER_NAME'];
        //echo $currdomain;
        $cdndomain = parse_url(get_option('bapi_site_cdn_domain'));
        //echo $cdndomain['host']; exit();
        //$url = ($_SERVER['SERVER_PORT']==443 ? get_option('bapi_site_cdn_domain') : "/");
        //if (empty($url)) { $url = "/"; }
        if ($currdomain == $cdndomain['host'] || is_admin() || is_super_admin()) {
            //Always link to subdomain if logged in as admin [Jacob]
            $url = '/';
            if ($_SERVER['SERVER_PORT'] == 443) {
                $url = 'http://' . $currdomain . '/';
            }
        } else {
            $url = get_option('bapi_site_cdn_domain');
        }
        ?>
        <div class="bapi-logo"><a href="<?php 
        echo $url;
        ?>
" ><img src="<?php 
        echo $logo;
        ?>
" alt="" /></a></div>
		<?php 
    }
Example #3
0
function booking_confirmation_sc()
{
    $td = getbapisolutiondata();
    $googleConversionkey = get_option('bapi_google_conversion_key');
    $googleConversionlabel = get_option('bapi_google_conversion_label');
    $googleConversionCode = '';
    if ($googleConversionkey != '' && $googleConversionlabel != '') {
        $googleConversionCode = '<!-- Google Code for Signup Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = ' . $googleConversionkey . ';
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "' . $googleConversionlabel . '";
var google_conversion_value = 0;
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
<noscript><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/' . $googleConversionkey . '/?value=0&label=' . $googleConversionlabel . '&guid=ON&script=0"/></div></noscript>';
    }
    $d = '<h1>Reservation Request Received</h1>
<p>Thank You! We have received your request and will process it shortly. Please note that your reservation is not confirmed until you receive written confirmation from us.</p>
<p>If you have any questions regarding this reservation, please <a href="mailto:' . $td['site']['PrimaryEmail'] . '">contact us.</a></p>' . $googleConversionCode;
    return $d;
}