Exemplo n.º 1
0
 public function save_post($post_id)
 {
     if (!isset($_POST['wpi_db_meta_box_nonce'])) {
         return;
     }
     if (!wp_verify_nonce($_POST["wpi_db_meta_box_nonce"], "wpi_db_meta_box")) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (!current_user_can("edit_post", $post_id)) {
         return;
     }
     //$field_names=WPiTools::get_field_names($this->fields());
     WPiData::update_post_meta($post_id, $this->fields());
 }
 public function designer_button($atts, $content = "")
 {
     $defaults = array("id" => "", "style_id" => "", "slide_id" => "", "share_id" => "", "twin_id" => "", "smart_id" => "", 'link' => '#', 'text' => 'button', "target" => "", "icon" => "", "display" => false, "icon_position" => "left", "rel" => "");
     $atts = shortcode_atts($defaults, $atts, "wpi_designer_button");
     $button = "";
     $output = "";
     if ($atts['slide_id'] != "") {
         $post = get_post($atts['slide_id']);
         $vars = array("slide_heading", "slide_heading_2", "slide_heading_3", "slide_text", "background_color", "background_image", "button_text", "button_link", "target", "slide_footer_text", "icon", "style_id");
         $slide_data = WPiData::get_post_meta($atts['slide_id'], $vars);
         $atts = array_merge($atts, $slide_data);
         $atts['link'] = $atts['button_link'];
         $atts['text'] = $atts['button_text'];
         $slide_class = "wpi_slide_" . $atts['slide_id'];
         //$output.=print_r($atts,true);
     } else {
         if ($atts['id'] != "") {
             $post = get_post($atts['id']);
             $atts['text'] = get_post_meta($atts['id'], "text", true);
             if ($atts['link'] == "" || $atts['link'] == "#") {
                 $atts['link'] = get_post_meta($atts['id'], "link", true);
             }
             if (has_shortcode($atts['text'], 'wpidb')) {
                 $atts['text'] = do_shortcode($atts['text']);
             }
             if (has_shortcode($atts['link'], 'wpidb')) {
                 $atts['link'] = do_shortcode($atts['link']);
             }
             $atts['link'] = $this->capture_vars(array("text" => $atts['link']));
             $atts['text'] = $this->capture_vars(array("text" => $atts['text']));
             $atts['target'] = get_post_meta($atts['id'], "target", true);
             $atts['icon'] = get_post_meta($atts['id'], "icon", true);
             $atts['icon_position'] = get_post_meta($atts['id'], "icon_position", true);
             $atts['style_id'] = get_post_meta($atts['id'], "style_id", true);
             $atts['rel'] = get_post_meta($atts['id'], "rel", true);
         } else {
             if ($atts['twin_id'] != "") {
                 $post = get_post($atts['twin_id']);
                 $atts['left_button_text'] = get_post_meta($atts['twin_id'], "left_button_text", true);
                 $atts['right_button_text'] = get_post_meta($atts['twin_id'], "right_button_text", true);
                 $atts['left_button_link'] = get_post_meta($atts['twin_id'], "left_button_link", true);
                 $atts['right_button_link'] = get_post_meta($atts['twin_id'], "right_button_link", true);
                 $atts['left_button_icon'] = get_post_meta($atts['twin_id'], "left_button_icon", true);
                 $atts['right_button_icon'] = get_post_meta($atts['twin_id'], "right_button_icon", true);
                 $atts['target'] = get_post_meta($atts['twin_id'], "target", true);
                 $atts['icon_position'] = get_post_meta($atts['twin_id'], "icon_position", true);
                 $atts['style_id'] = get_post_meta($atts['twin_id'], "style_id", true);
                 if ($atts['left_button_icon'] != "") {
                     $left_button_icon_class = "wpi_icon wpi_icon_" . $atts['left_button_icon'] . " " . $icon_position;
                 } else {
                     $left_button_icon_class = "";
                 }
                 if ($atts['right_button_icon'] != "") {
                     $right_button_icon_class = "wpi_icon wpi_icon_" . $atts['right_button_icon'] . " " . $icon_position;
                 } else {
                     $right_button_icon_class = "";
                 }
             } else {
                 if ($atts['smart_id'] != "") {
                     $post = get_post($atts['smart_id']);
                     $atts['button_text'] = get_post_meta($atts['smart_id'], "button_text", true);
                     $atts['button_icon'] = get_post_meta($atts['smart_id'], "button_icon", true);
                     $atts['style_id'] = get_post_meta($atts['smart_id'], "style_id", true);
                     for ($i = 1; $i <= 5; $i++) {
                         $atts['heading' . $i] = get_post_meta($atts['smart_id'], "heading" . $i, true);
                         $atts['subheading' . $i] = get_post_meta($atts['smart_id'], "subheading" . $i, true);
                     }
                     if ($atts['button_icon'] != "") {
                         $button_icon_class = "wpi_icon wpi_icon_" . $atts['button_icon'];
                     } else {
                         $button_icon_class = "";
                     }
                 }
             }
         }
     }
     $classes = WPiDesButCommon::get_button_style_class($atts['style_id']);
     if ($atts['icon_position'] == "right") {
         $left_icon = "";
         $right_icon = "<i class=''></i>";
         $icon_position = "wpi_icon_right";
     } else {
         $left_icon = "<i class=''></i>";
         $right_icon = "";
         $icon_position = "wpi_icon_left";
     }
     if ($atts['icon'] != "") {
         $icon_class = "wpi_icon wpi_icon_" . $atts['icon'] . " " . $icon_position;
     } else {
         $icon_class = "";
     }
     if ($atts['display'] == true) {
         $display_class = "wpi_display";
     } else {
         $display_class = "";
     }
     if (trim($atts['text']) == "") {
         $no_text_class = "wpi_no_text";
     } else {
         $no_text_class = "";
     }
     $target = strtolower(trim($atts['target']));
     if ($target == "new window" || $target == "newwindow" || $target == "_blank") {
         $atts['target'] = $target;
     } else {
         $atts['target'] = "";
     }
     $button .= "<a href='" . $atts['link'] . "' class='wpi_designer_button {$classes} {$icon_class} {$display_class} {$no_text_class}' target='" . $atts['target'] . "' rel='" . $atts['rel'] . "'>" . $left_icon . "<span class='wpi_text'>" . $atts['text'] . "</span>" . $right_icon . "</a>";
     if ($atts['slide_id'] != "") {
         $output .= "<div class='wpi_slide {$slide_class}'>";
         $output .= "<div class='wpi_slide_image'></div>";
         $output .= "<div id='wpi_slide_content' >";
         $output .= "<div class='wpi_slide_heading'>";
         if ($atts['slide_heading'] != "") {
             $output .= "<div><span>" . $atts['slide_heading'] . "</span></div>";
         }
         if ($atts['slide_heading_2'] != "") {
             $output .= "<div><span style='display:none'>" . $atts['slide_heading_2'] . "</span></div>";
         }
         if ($atts['slide_heading_3'] != "") {
             $output .= "<div><span style='display:none'>" . $atts['slide_heading_3'] . "</span></div>";
         }
         $output .= "</div>";
         $output .= "<div class='wpi_slide_text'>" . $atts['slide_text'] . "</div>";
         if ($atts['text'] != "") {
             $output .= $button;
         }
         $output .= "</div>";
         $output .= "<div class='wpi_slide_footer' >" . $atts['slide_footer_text'] . "</div>";
         $output .= "</div>";
     } else {
         if ($atts['share_id'] != "") {
             $style_id = get_post_meta($atts['share_id'], "style_id", true);
             $link = urlencode(self::current_page_url());
             $title = the_title_attribute('echo=0');
             $fromurl = "";
             $desc = "";
             $imagelink = "";
             $buttons_data = array("facebook" => array("link" => "https://www.facebook.com/sharer/sharer.php?u=" . $link, "icon" => "facebook-alt", "color" => "", "title" => "Share on  Facebook"), "twitter" => array("link" => "https://twitter.com/intent/tweet?source=" . $link . "&text=" . $title . "&via=" . $fromurl, "icon" => "twitter", "color" => "", "title" => "Tweet"), "googleplus" => array("link" => "https://plus.google.com/share?url=" . $link, "icon" => "googleplus-alt", "color" => "", "title" => "Share on Google+"), "linkedin" => array("link" => "http://www.linkedin.com/shareArticle?mini=true&url=" . $link . "&title=" . $title . "&summary=" . $desc . "&source=" . $fromurl, "icon" => "linkedin", "color" => "", "title" => "Share on LinkedIn"), "pinterest" => array("link" => "http://pinterest.com/pin/create/button/?url=" . $link . "&media=" . $imagelink . "&description=" . $desc, "icon" => "pinterest", "color" => "", "title" => "Pin it"), "tumblr" => array("link" => "http://www.tumblr.com/share?v=3&u=" . $link . "&t=" . $title . "&s=", "icon" => "tumblr", "color" => "", "title" => "Post on Tumblr"), "stumbleupon" => array("link" => "http://www.stumbleupon.com/submit?url=" . $link, "icon" => "stumbleupon", "color" => "", "title" => "Share on  Stumbleupon"), "reddit" => array("link" => "http://www.reddit.com/submit?url=" . $link . "&title=" . $title, "icon" => "reddit", "color" => "", "title" => "Submit to Reddit"), "wordpress" => array("link" => "http://wordpress.com/press-this.php?u=" . $link . "&t=" . $title . "&s=" . $desc . "&i=" . $imagelink, "icon" => "wordpress", "color" => "", "title" => "Publish on WordPress"), "email" => array("link" => "mailto:?subject=" . $title . "&body=" . $desc . ":" . $link, "icon" => "mail", "color" => "", "title" => "Email"));
             $share_buttons = "<div class='wpi_share_buttons wpi_share_buttons_" . $atts['share_id'] . "'>\n\t\t\t\t<div id='wpi_sb_text' class='wpi_sb_text'>Share on :</div><ul>";
             foreach ($buttons_data as $k => $v) {
                 $state = get_post_meta($atts['share_id'], $k, true);
                 if ($state == 1) {
                     $display = "";
                 } else {
                     $display = "wpi_none";
                 }
                 $share_buttons .= "<li class='wpi_sb_" . $k . " " . $display . "'><a href='" . $v['link'] . "' target='_blank' title='" . $v['title'] . "' class='wpi_designer_button wpi_designer_button_{$style_id} wpi_no_text wpi_icon wpi_icon_" . $v['icon'] . "' href='#'><i></i></a></li>";
             }
             $share_buttons .= "</ul></div>";
             $output .= $share_buttons;
         } else {
             if ($atts['twin_id'] != "") {
                 $l_style_id = get_post_meta($atts['twin_id'], "style_id", true);
                 $r_style_id = $l_style_id;
                 $left_button_style_id = get_post_meta($atts['twin_id'], "left_button_style_id", true);
                 $right_button_style_id = get_post_meta($atts['twin_id'], "right_button_style_id", true);
                 if ($left_button_style_id != "" && $left_button_style_id != "0") {
                     $l_style_id = $left_button_style_id;
                 }
                 if ($right_button_style_id != "" && $right_button_style_id != "0") {
                     $r_style_id = $right_button_style_id;
                 }
                 $l_classes = WPiDesButCommon::get_button_style_class($l_style_id);
                 $r_classes = WPiDesButCommon::get_button_style_class($r_style_id);
                 $twin_buttons = "<div class='wpi_twin_buttons wpi_twin_button_" . $atts['twin_id'] . "'>";
                 $twin_buttons .= "<a href='" . $atts['left_button_link'] . "' class='wpi_left_button wpi_designer_button {$l_classes} {$left_button_icon_class} {$display_class} {$no_text_class}' target='" . $atts['target'] . "' >" . $left_icon . "<span class='wpi_text'>" . $atts['left_button_text'] . "</span>" . $right_icon . "<span class='wpi_or_txt'>or</span></a>";
                 $twin_buttons .= "<a href='" . $atts['right_button_link'] . "' class='wpi_right_button wpi_designer_button {$r_classes} {$right_button_icon_class} {$display_class} {$no_text_class}' target='" . $atts['target'] . "' >" . $left_icon . "<span class='wpi_text'>" . $atts['right_button_text'] . "</span>" . $right_icon . "</a>";
                 $twin_buttons .= "</div>";
                 $output .= $twin_buttons;
             } else {
                 if ($atts['smart_id'] != "") {
                     $style_id = get_post_meta($atts['smart_id'], "style_id", true);
                     $classes = WPiDesButCommon::get_button_style_class($style_id);
                     if (trim($atts['button_text']) == "") {
                         $no_text_class = "wpi_no_text";
                     } else {
                         $no_text_class = "";
                     }
                     $smart_buttons .= "<div class='wpi_smart_buttons  wpi_smart_button_" . $atts['smart_id'] . "''>\n\t\t\t<ul class='wpi_menu_links wpi_close'>\t\t\t\n\t\t\t<li><div><span class='wpi_heading'>" . $atts['heading1'] . "</span> <span class='wpi_subheading'>" . $atts['subheading1'] . "</span></div><a href=''></a></li>\n\t\t\t<li><div><span class='wpi_heading'>" . $atts['heading2'] . "</span> <span class='wpi_subheading'>" . $atts['subheading2'] . "</span></div><a href=''></a></li>\n\t\t\t<li><div><span class='wpi_heading'>" . $atts['heading3'] . "</span> <span class='wpi_subheading'>" . $atts['subheading3'] . "</span></div><a href=''></a></li>\n\t\t\t<li><div><span class='wpi_heading'>" . $atts['heading4'] . "</span> <span class='wpi_subheading'>" . $atts['subheading4'] . "</span></div><a href=''></a></li>\n\t\t\t<li><div><span class='wpi_heading'>" . $atts['heading5'] . "</span> <span class='wpi_subheading'>" . $atts['subheading5'] . "</span></div><a href=''></a></li>\n\t\t\t</ul>\n\t\t\t<a class='wpi_designer_button {$classes} {$button_icon_class} {$display_class} {$no_text_class} wpi_toggle_close' href='#'><i class='wpi_icon'></i><span class='wpi_text'>" . $atts['button_text'] . "</span></a> <a class='wpi_designer_button {$classes} wpi_icon wpi_icon_facebook href='#'><i class='wpi_icon'></i><span class='wpi_text'>Facebook</span></a> <a class='wpi_designer_button {$classes} wpi_icon wpi_icon_twitter href='#'><i class='wpi_icon'></i><span class='wpi_text'>Twitter</span></a>\t\t\n\t\t\t</div>";
                     $output .= $smart_buttons;
                 } else {
                     $output .= $button . $atts['slide_id'];
                 }
             }
         }
     }
     return $output;
 }
Exemplo n.º 3
0
 public static function html($post_id, $args = array())
 {
     $holder = "";
     if ($post_id != "") {
         foreach ($args as $k => $v) {
             $args[$k]['value'] = WPiData::get_post_meta($post_id, $args[$k]['name']);
         }
         $holder = self::create_holder($args);
     }
     return $holder;
 }
Exemplo n.º 4
0
    public static function html($post_id, $args = array())
    {
        $sec_alt = 0;
        $c = 0;
        $out = "";
        $section = "";
        $html = "";
        $ss = array();
        foreach ($args as $arg) {
            if (isset($arg['section']) && $arg['section'] != "" && isset($arg['name']) && $arg['name'] != "") {
                $section_name = $arg['section'];
            } else {
                $section_name = 'settings';
            }
            $sections[$section_name]['backup'][] = $arg;
        }
        foreach ($sections as $key => $section) {
            foreach ($section['backup'] as $data) {
                if (isset($data['group']) && $data['group'] != "") {
                    $group_name = $data['group'];
                } else {
                    $group_name = 'no_group';
                }
                $sections[$key][$group_name][] = $data;
            }
            unset($sections[$key]['backup']);
        }
        $header = '
		<div class="wpi_header">
			<span class="wpi_menu genericon genericon-menu">
			  <div class="wpi_back genericon genericon-previous"></div>      
			</span>
			<span class="wpi_heading">Settings</span>
		  </div><!-- header--> ';
        $sec = '<div class="wpi_sections">';
        foreach ($sections as $key => $section) {
            $sec .= '<div class="wpi_section" data-target_id="' . sanitize_title($key) . '" data-target="' . $key . '">' . $key . '<div class="wpi_open genericon genericon-next"></div></div>';
        }
        $sec .= '</div><!-- sections-->';
        $c = 0;
        $sections_content = '<div class="wpi_sections_content">';
        foreach ($sections as $key => $section) {
            if ($c == 0) {
                $visible = "";
            } else {
                $visible = "wpi_none";
            }
            $c++;
            $sections_content .= '<div class="wpi_section_content ' . $visible . '" id="' . sanitize_title($key) . '">';
            $sections_content .= '<div class="wpiAccordion">';
            foreach ($section as $group_key => $group) {
                $sections_content .= '<li>';
                if ($group_key == "no_group") {
                    $sections_content .= '<h3>All<i class="genericon genericon-next"></i></h3>';
                } else {
                    $sections_content .= '<h3>' . $group_key . ' <i class="genericon genericon-next"></i></h3>';
                }
                $sections_content .= '<div class="wpi_accordion_content">';
                foreach ($group as $data) {
                    $data['value'] = WPiData::get_post_meta($post_id, $data['name']);
                    if ($data['type'] == "text") {
                        $input = WPiControls::text(array("name" => $data['name'], "value" => $data['value']));
                    } else {
                        if ($data['type'] == "textarea") {
                            $input = WPiControls::textarea(array("name" => $data['name'], "value" => $data['value']));
                        } else {
                            if ($data['type'] == "hidden") {
                                $input = WPiControls::hidden(array("name" => $data['name'], "value" => $data['value']));
                            } else {
                                if ($data['type'] == "button") {
                                    $input = WPiControls::button(array("name" => $data['name'], "value" => $data['value']));
                                } else {
                                    if ($data['type'] == "wp_image") {
                                        $input = WPiControls::wp_image(array("name" => $data['name'], "value" => $data['value']));
                                    } else {
                                        if ($data['type'] == "select") {
                                            $input = WPiControls::select(array("name" => $data['name'], "value" => $data['value'], "list" => $data['list']));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($data['type'] != "hidden") {
                        $sections_content .= '<div class="label">' . $data['label'] . '</div>';
                    }
                    $sections_content .= '<div class="input">' . $input . '</div>';
                }
                $sections_content .= '</div><!-- accordion_content-->';
                $sections_content .= '</li>';
            }
            $sections_content .= '</div><!-- wpiAccordion-->';
            $sections_content .= '</div><!-- section content-->';
        }
        $sections_content .= '</div><!-- sections content-->';
        $html .= '<div  class="wpiHolder">';
        $html .= $header;
        $html .= '<div class="wpi_content"><div class="wpi_content_holder">';
        $html .= $sec;
        $html .= $sections_content;
        $html .= "</div><!-- content holder--></div><!-- content-->";
        $html .= "</div><!-- wpiHolder-->";
        $sample = '<div class="wpiHolder">
		  <div class="wpi_header">
			<span class="wpi_menu genericon genericon-menu">
			  <div class="wpi_back genericon genericon-previous"></div>      
			</span>
			<span class="wpi_heading">Settings</span>
		  </div><!-- header-->  
		  <div class="wpi_content">
			<div class="wpi_content_holder">
			  <div class="wpi_sections">
				<div class="wpi_section" data-target_id="heading_settings" data-target="Heading settings">Slide Heading </div>
				<div class="wpi_section" data-target_id="text_settings" data-target="Text settings">Slide Text</div>
			  </div><!-- sections-->
			  <div class="wpi_sections_content">
				<div class="wpi_section_content" id="heading_settings">
				  <div class="label">Heading</div>
				  <div class="input"><input type="text" value="heading"/></div>
				</div><!-- section content-->
				<div class="wpi_section_content" id="text_settings">
				  <div class="label">Text</div>
				  <div class="input"><input type="text" value="text"/></div>
				</div><!-- section content-->
			  </div><!-- sections content-->
			</div><!-- content holder-->
		  </div><!-- content-->
		</div><!-- wpiHolder-->';
        return $html;
        //$out=print_r($sections,true);
        //return $out;
    }