コード例 #1
1
function motopressCERemoveTemporaryPost()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../Requirements.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    require_once dirname(__FILE__) . '/ThemeFix.php';
    global $motopressCESettings;
    $motopressCELang = motopressCEGetLanguageDict();
    $errors = array();
    $post_id = $_POST['post_id'];
    $post = get_post($post_id);
    if (!is_null($post)) {
        $delete = wp_trash_post($post_id);
        new MPCEThemeFix(MPCEThemeFix::ACTIVATE);
        if ($delete === false) {
            $errors[] = $motopressCELang->CERemoveTemporaryPostError;
        }
    }
    if (!empty($errors)) {
        if ($motopressCESettings['debug']) {
            print_r($errors);
        } else {
            motopressCESetError($motopressCELang->CERemoveTemporaryPostError);
        }
    }
    exit;
}
コード例 #2
0
function motopressCEGetAttachmentThumbnail()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    $motopressCELang = motopressCEGetLanguageDict();
    if (isset($_POST['id']) && !empty($_POST['id'])) {
        $id = (int) trim($_POST['id']);
        $attachment = get_post($id);
        if (!empty($attachment) && $attachment->post_type === 'attachment') {
            if (wp_attachment_is_image($id)) {
                $srcMedium = wp_get_attachment_image_src($id, 'medium');
                $srcFull = wp_get_attachment_image_src($id, 'full');
                if (isset($srcMedium[0]) && !empty($srcMedium[0]) && isset($srcFull[0]) && !empty($srcFull[0])) {
                    $attachmentImageSrc = array();
                    $attachmentImageSrc['medium'] = $srcMedium[0];
                    $attachmentImageSrc['full'] = $srcFull[0];
                    wp_send_json($attachmentImageSrc);
                } else {
                    motopressCESetError($motopressCELang->CEAttachmentImageSrc);
                }
            } else {
                motopressCESetError($motopressCELang->CEAttachmentNotImage);
            }
        } else {
            motopressCESetError($motopressCELang->CEAttachmentEmpty);
        }
    } else {
        motopressCESetError($motopressCELang->CEAttachmentThumbnailError);
    }
    exit;
}
コード例 #3
0
ファイル: renderShortcode.php プロジェクト: umang11/glotech
function motopressCERenderShortcode()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    require_once dirname(__FILE__) . '/Shortcode.php';
    $motopressCELang = motopressCEGetLanguageDict();
    if (isset($_POST['closeType']) && !empty($_POST['closeType']) && isset($_POST['shortcode']) && !empty($_POST['shortcode'])) {
        global $motopressCESettings;
        $errors = array();
        $closeType = $_POST['closeType'];
        $shortcode = $_POST['shortcode'];
        $parameters = null;
        if (isset($_POST['parameters']) && !empty($_POST['parameters'])) {
            $parameters = json_decode(stripslashes($_POST['parameters']));
            if (!$parameters) {
                $errors[] = $motopressCELang->CERenderShortcodeError;
            }
        }
        $styles = null;
        if (isset($_POST['styles']) && !empty($_POST['styles'])) {
            $styles = json_decode(stripslashes($_POST['styles']));
            if (!$styles) {
                $errors[] = $motopressCELang->CERenderShortcodeError;
            }
        }
        if (empty($errors)) {
            do_action('motopress_render_shortcode', $shortcode);
            $s = new MPCEShortcode();
            $content = null;
            if (isset($_POST['content']) && !empty($_POST['content'])) {
                $content = stripslashes($_POST['content']);
                if (isset($_POST['wrapRender']) && $_POST['wrapRender'] === 'true') {
                    $content = motopressCECleanupShortcode($content);
                    global $motopressCELibrary;
                    $motopressCELibrary = new MPCELibrary();
                    $content = motopressCEParseObjectsRecursive($content);
                }
            }
            $str = $s->toShortcode($closeType, $shortcode, $parameters, $styles, $content);
            echo do_shortcode($str);
        }
        if (!empty($errors)) {
            if ($motopressCESettings['debug']) {
                print_r($errors);
            } else {
                motopressCESetError($motopressCELang->CERenderShortcodeError);
            }
        }
    } else {
        motopressCESetError($motopressCELang->CERenderShortcodeError);
    }
    exit;
}
コード例 #4
0
function motopressCERenderContent()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../Requirements.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    require_once dirname(__FILE__) . '/postMetaFix.php';
    require_once dirname(__FILE__) . '/ThemeFix.php';
    $content = trim($_POST['data']);
    $post_id = $_POST['post_id'];
    global $motopressCESettings;
    $motopressCELang = motopressCEGetLanguageDict();
    $errors = array();
    global $motopressCELibrary;
    $motopressCELibrary = new MPCELibrary();
    do_action_ref_array('mp_library', array(&$motopressCELibrary));
    $content = stripslashes($content);
    $content = motopressCECleanupShortcode($content);
    if (!empty($content)) {
        $content = motopressCEWrapOuterCode($content);
    }
    $output = motopressCEParseObjectsRecursive($content);
    $tmp_post_id = motopressCECreateTemporaryPost($post_id, $output);
    if ($tmp_post_id !== 0) {
        $themeFix = new MPCEThemeFix(MPCEThemeFix::DEACTIVATE);
        $src = get_permalink($tmp_post_id);
        //@todo: fix protocol for http://codex.wordpress.org/Administration_Over_SSL
        //fix different site (WordPress Address) and home (Site Address) url for iframe security
        $siteUrl = get_site_url();
        $homeUrl = get_home_url();
        $siteUrlArr = parse_url($siteUrl);
        $homeUrlArr = parse_url($homeUrl);
        if ($homeUrlArr['scheme'] !== $siteUrlArr['scheme'] || $homeUrlArr['host'] !== $siteUrlArr['host']) {
            $src = str_replace($homeUrl, $siteUrl, $src);
        }
        $result = array('post_id' => $tmp_post_id, 'src' => $src, 'headway_themes' => $themeFix->isHeadwayTheme());
        echo json_encode($result);
    } else {
        $errors[] = $motopressCELang->CECreateTemporaryPostError;
    }
    if (!empty($errors)) {
        if ($motopressCESettings['debug']) {
            print_r($errors);
        } else {
            motopressCESetError($motopressCELang->CECreateTemporaryPostError);
        }
    }
    exit;
}
コード例 #5
0
ファイル: updatePalettes.php プロジェクト: umang11/glotech
function motopressCEupdatePalettes()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    $motopressCELang = motopressCEGetLanguageDict();
    if (isset($_POST['palettes']) && !empty($_POST['palettes'])) {
        $palettes = $_POST['palettes'];
        update_option('motopress-palettes', $palettes);
        echo json_encode(array('palettes' => $palettes));
    } else {
        motopressCESetError($motopressCELang->CEColorpickerPalettesError);
    }
    exit;
}
コード例 #6
0
ファイル: feature.php プロジェクト: xav335/sfnettoyage
<?php

global $motopressCESettings;
require_once $motopressCESettings['plugin_root'] . '/' . $motopressCESettings['plugin_name'] . '/includes/getLanguageDict.php';
$motopressCELang = motopressCEGetLanguageDict();
$defaultText = $motopressCELang->CEContentDefault;
$featureContent = <<<CONTENT
[mp_row]

[mp_span col="6"]

[mp_image size="full" link_type="custom_url" link="#" target="false" align="left"]

[/mp_span]

[mp_span col="6"]

[mp_text]
{$defaultText}
[/mp_text]

[/mp_span]

[/mp_row]

[mp_row]

[mp_span col="6"]

[mp_text]
{$defaultText}
コード例 #7
0
ファイル: Shortcode.php プロジェクト: kittu57/Access-story
 public function motopressTable($attrs, $content = null)
 {
     extract(shortcode_atts(self::addStyleAtts(array()), $attrs));
     global $motopressCESettings;
     require_once $motopressCESettings['plugin_root'] . '/' . $motopressCESettings['plugin_name'] . '/includes/getLanguageDict.php';
     $motopressCELang = motopressCEGetLanguageDict();
     if (!empty($classes)) {
         $classes = ' ' . $classes;
     }
     if (self::$isNeedFix && empty($mp_style_classes)) {
         if (!empty($style) && $style != 'none') {
             $mp_style_classes = 'motopress-table-style-' . $style;
         }
         if (!empty($custom_class)) {
             $mp_style_classes .= ' ' . $custom_class;
         }
     }
     if (!empty($mp_style_classes)) {
         $mp_style_classes = ' ' . $mp_style_classes;
     }
     $result = '<div class="motopress-table-obj' . self::getMarginClasses($margin) . $classes . '">';
     $content = trim($content);
     $content = preg_replace('/^<p>|<\\/p>$/', '', $content);
     $content = preg_replace('/<br[^>]*>\\s*\\r*\\n*/is', "\n", $content);
     if (!empty($content)) {
         //            $result .= '<table class="' . self::getBasicClasses(self::PREFIX . 'table', true) . $mp_style_classes   . '">';
         $result .= '<table class="' . self::getBasicClasses(self::PREFIX . 'table') . $mp_style_classes . '">';
         $i = 0;
         if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
             $rows = explode("\n", $content);
             $rowsCount = count($rows);
             foreach ($rows as $row) {
                 $row = str_getcsv($row);
                 $isLast = $i === $rowsCount - 1 ? true : false;
                 self::addRow($row, $i, $isLast, $result);
                 $i++;
             }
         } else {
             $tmpFile = new SplTempFileObject();
             $tmpFile->setFlags(SplFileObject::SKIP_EMPTY);
             $tmpFile->setFlags(SplFileObject::DROP_NEW_LINE);
             $write = $tmpFile->fwrite($content);
             if (!is_null($write)) {
                 $tmpFile->rewind();
                 while (!$tmpFile->eof()) {
                     $row = $tmpFile->fgetcsv();
                     $isLast = $tmpFile->eof();
                     self::addRow($row, $i, $isLast, $result);
                     $i++;
                 }
             }
         }
         $result .= '</table>';
     } else {
         $result .= $motopressCELang->CETableObjNoData;
     }
     $result .= '</div>';
     return $result;
 }
コード例 #8
0
function motopressCEAdminBarMenu($wp_admin_bar)
{
    if (is_admin_bar_showing() && !is_admin() && !is_preview()) {
        global $wp_the_query, $motopressCESettings;
        $current_object = $wp_the_query->get_queried_object();
        if (!empty($current_object) && !empty($current_object->post_type) && ($post_type_object = get_post_type_object($current_object->post_type)) && $post_type_object->show_ui && $post_type_object->show_in_admin_bar) {
            require_once 'includes/ce/Access.php';
            $ceAccess = new MPCEAccess();
            $postType = get_post_type();
            $postTypes = get_option('motopress-ce-options');
            if (!$postTypes) {
                $postTypes = array();
            }
            if (in_array($postType, $postTypes) && post_type_supports($postType, 'editor') && $ceAccess->hasAccess($current_object->ID)) {
                require_once 'includes/getLanguageDict.php';
                $motopressCELang = motopressCEGetLanguageDict();
                $isHideLinkEditWith = apply_filters('mpce_hide_link_edit_with', false);
                if (!$isHideLinkEditWith) {
                    $wp_admin_bar->add_menu(array('href' => get_edit_post_link($current_object->ID) . '&motopress-ce-auto-open=true', 'parent' => false, 'id' => 'motopress-edit', 'title' => strtr($motopressCELang->CEAdminBarMenu, array('%BrandName%' => $motopressCESettings['brand_name'])), 'meta' => array('title' => strtr($motopressCELang->CEAdminBarMenu, array('%BrandName%' => $motopressCESettings['brand_name'])), 'onclick' => 'sessionStorage.setItem("motopressPluginAutoOpen", true);')));
                }
            }
        }
    }
}
コード例 #9
0
ファイル: Shortcode.php プロジェクト: xav335/sfnettoyage
    public function motopressPostsGrid($attrs, $content = null)
    {
        $defaultAttrs = array('query_type' => 'simple', 'post_type' => 'post', 'columns' => 3, 'category' => '', 'tag' => '', 'posts_per_page' => 3, 'posts_order' => 'DESC', 'custom_tax' => '', 'custom_tax_field' => '', 'custom_tax_terms' => '', 'custom_query' => '', 'ids' => '', 'template' => '/plugins/motopress-content-editor/includes/ce/shortcodes/post_grid/templates/template1.php', 'posts_gap' => 30, 'show_featured_image' => 'true', 'image_size' => 'large', 'image_custom_size' => '', 'title_tag' => 'h2', 'show_date_comments' => 'true', 'show_content' => 'short', 'short_content_length' => 200, 'read_more_text' => '', 'pagination' => 'false', 'load_more_btn' => 'false', 'load_more_text' => 'Load More', 'is_ajax' => false, 'ajax_paged' => 1);
        $ajaxAttrs = array_merge($defaultAttrs, $attrs);
        extract(shortcode_atts(self::addStyleAtts($defaultAttrs), $attrs));
        $motopressCELang = motopressCEGetLanguageDict();
        $result = '';
        $gridId = 'posts_grid_' . uniqid();
        $exclude_posts = array();
        if (self::isContentEditor()) {
            if (isset($_POST['postID']) && !empty($_POST['postID'])) {
                $id = $_POST['postID'];
                $exclude_posts[] = (int) $_POST['postID'];
            } else {
                $id = get_the_ID();
            }
            $editedPost = get_post_meta($id, 'motopress-ce-edited-post', true);
            if (!empty($editedPost)) {
                $exclude_posts[] = (int) $editedPost;
            }
            if (isset($_GET['p'])) {
                $exclude_posts[] = (int) $_GET['p'];
            }
        } else {
            wp_enqueue_style('mpce-bootstrap-grid');
            $id = get_the_ID();
            $exclude_posts = array($id);
        }
        $paged = isset($_GET['mp_posts_grid_paged']) ? $_GET['mp_posts_grid_paged'] : 1;
        if ($is_ajax) {
            $paged = (int) $ajax_paged;
        }
        $args = array();
        switch ($query_type) {
            case 'simple':
                $tax_query = array();
                if (isset($category) && !empty($category)) {
                    $tax_query_cat = array('taxonomy' => 'category', 'field' => 'slug');
                    if (strpos($category, '+') !== false && strpos($category, ',') !== false) {
                        $cat_regex = '/[+,\\s]+/';
                    } else {
                        if (strpos($category, '+') !== false) {
                            $tax_query_cat['operator'] = 'AND';
                            $cat_regex = '/[+\\s]+/';
                        } else {
                            $cat_regex = '/[,\\s]+/';
                        }
                    }
                    $tax_query_cat['terms'] = array_unique(preg_split($cat_regex, $category));
                    $tax_query[] = $tax_query_cat;
                }
                if (isset($tag) && !empty($tag)) {
                    $tax_query_tag = array('taxonomy' => 'post_tag', 'field' => 'slug');
                    if (strpos($tag, '+') !== false && strpos($tag, ',') !== false) {
                        $tag_regex = '/[+,\\s]+/';
                    } else {
                        if (strpos($tag, '+') !== false) {
                            $tax_query_tag['operator'] = 'AND';
                            $tag_regex = '/[+\\s]+/';
                        } else {
                            $tag_regex = '/[,\\s]+/';
                        }
                    }
                    $tax_query_tag['terms'] = array_unique(preg_split($tag_regex, $tag));
                    $tax_query[] = $tax_query_tag;
                }
                if (!empty($custom_tax) && !empty($custom_tax_field) && !empty($custom_tax_terms)) {
                    $tax_query_defaults = array('taxonomy' => $custom_tax, 'field' => $custom_tax_field);
                    if (strpos($custom_tax_terms, '+') !== false) {
                        $terms = preg_split('/[+]+/', $custom_tax_terms);
                        foreach ($terms as $term) {
                            $tax_query[] = array_merge($tax_query_defaults, array('terms' => array($term)));
                        }
                    } else {
                        $tax_query[] = array_merge($tax_query_defaults, array('terms' => preg_split('/[,]+/', $custom_tax_terms)));
                    }
                }
                $args = array('post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'post__not_in' => $exclude_posts, 'order' => $posts_order, 'paged' => $paged);
                if (!empty($tax_query)) {
                    $args['tax_query'] = $tax_query;
                }
                break;
            case 'custom':
                if (!empty($custom_query)) {
                    $custom_query = base64_decode($custom_query);
                    $custom_query = html_entity_decode($custom_query);
                    wp_parse_str($custom_query, $args);
                    if (isset($args['post__not_in'])) {
                        if (is_array($args['post__not_in'])) {
                            $args['post__not_in'] = array_unique(array_merge($args['post__not_in'], $exclude_posts));
                        }
                    } else {
                        if (isset($args['post__in'])) {
                            if (is_array($args['post__in'])) {
                                $args['post__in'] = array_diff($args['post__in'], $exclude_posts);
                            }
                        } else {
                            $args['post__not_in'] = $exclude_posts;
                        }
                    }
                    if (isset($args['posts_per_page'])) {
                        $args['paged'] = $paged;
                    }
                }
                break;
            case 'ids':
                if (!empty($ids)) {
                    $args = array('post_type' => 'any', 'post__in' => array_diff(explode(',', $ids), $exclude_posts), 'orderby' => 'post__in', 'paged' => $paged);
                }
                break;
        }
        if (!$is_ajax) {
            $args['no_found_rows'] = false;
        } else {
            $args['no_found_rows'] = true;
        }
        $custom_query = new WP_Query($args);
        $pagesCount = $custom_query->max_num_pages;
        $url = get_permalink();
        $url .= is_null(parse_url($url, PHP_URL_QUERY)) ? '?mp_posts_grid_paged=' : '&mp_posts_grid_paged=';
        $nextpage = $paged + 1;
        $prevpage = $paged - 1;
        if (self::$isNeedFix && empty($mp_style_classes)) {
            if (!empty($custom_class)) {
                $mp_style_classes .= ' ' . $custom_class;
            }
        }
        if (!empty($mp_style_classes)) {
            $mp_style_classes = ' ' . $mp_style_classes;
        }
        if ($image_size === 'custom') {
            $featured_image_size = array_pad(explode('x', $image_custom_size), 2, 0);
        } else {
            $featured_image_size = $image_size;
        }
        if ($custom_query->have_posts()) {
            $i = 0;
            $result .= '<div class="mp-row-fluid">';
            while ($custom_query->have_posts()) {
                $custom_query->the_post();
                self::setCurPostData(null, get_the_ID());
                $result .= '<div class="mp-span' . 12 / $columns . ' grid-item">';
                ob_start();
                require WP_CONTENT_DIR . '/' . $template;
                $result .= ob_get_contents();
                ob_end_clean();
                $result .= '</div>';
                if ($i % $columns == $columns - 1 && $i != $custom_query->post_count - 1) {
                    $result .= '</div>';
                    $result .= '<div class="mp-row-fluid">';
                }
                $i++;
            }
            $result .= '</div>';
            if (!$is_ajax) {
                if ($pagination == 'true' && $load_more_btn == 'false') {
                    if (isset($posts_order) && $posts_order === 'ASC') {
                        $nextPageLabel = $motopressCELang->CEPostsGridObjNewerPosts;
                        $prevPageLabel = $motopressCELang->CEPostsGridObjOlderPosts;
                    } else {
                        $nextPageLabel = $motopressCELang->CEPostsGridObjOlderPosts;
                        $prevPageLabel = $motopressCELang->CEPostsGridObjNewerPosts;
                    }
                    $result .= '<div class="mp-row-fluid motopress-posts-grid-pagination">';
                    if ($paged > 1) {
                        $result .= '<div class="nav-prev"><a href="' . $url . $prevpage . '"><span class="meta-nav">&#8592;</span>' . $prevPageLabel . '</a></div>';
                    }
                    if ($paged < $custom_query->max_num_pages) {
                        $result .= '<div class="nav-next"><a href="' . $url . $nextpage . '">' . $nextPageLabel . '<span class="meta-nav">&#8594;</span></a></div>';
                    }
                    $result .= '</div>';
                } else {
                    if ($load_more_btn == 'true') {
                        if ($paged < $pagesCount) {
                            global $motopressCESettings;
                            wp_enqueue_script('mp-posts-grid', $motopressCESettings['plugin_dir_url'] . 'includes/js/mp-posts-grid.js');
                            wp_localize_script('mp-posts-grid', 'mp_posts_grid', array('ajaxUrl' => admin_url('admin-ajax.php')));
                            $loadMoreScript = '<p class="motopress-hide-script">';
                            ob_start();
                            ?>
                                <script type="text/javascript">
                                    function loadMorePostsFor<?php 
                            echo $gridId;
                            ?>
() {
                                        var data = {
                                            action: 'motopress_posts_grid_load_more',
                                            <?php 
                            foreach ($ajaxAttrs as $name => $value) {
                                if ($name !== 'ajax_paged') {
                                    echo $name . ': "' . $value . '",';
                                }
                            }
                            ?>
                                            ajax_paged: 1 // Change it in motoLoadMorePosts
                                        };
                                        motoLoadMorePosts('<?php 
                            echo $gridId;
                            ?>
', data);
                                    }
                                </script>
                            <?php 
                            $loadMoreScript .= ob_get_clean();
                            $loadMoreScript .= '</p>';
                            $result .= '<div class="mp-row-fluid motopress-posts-grid-load-more">';
                            $result .= '<a href="#" class="motopress-btn motopress-btn-size-middle motopress-btn-rounded" onclick="loadMorePostsFor' . $gridId . '(); return false;">' . $load_more_text . '</a>';
                            $result .= $loadMoreScript;
                            $result .= '</div>';
                        }
                    }
                }
            }
        } else {
            if (!$is_ajax) {
                $result .= '<p>No posts of this post-type found.</p>';
            } else {
                return false;
            }
        }
        if (!$is_ajax) {
            $result = '<div id="' . $gridId . '" class="motopress-posts-grid-obj motopress-posts-grid-gap-' . $posts_gap . self::getMarginClasses($margin) . self::getBasicClasses(self::PREFIX . 'posts_grid', true) . $mp_style_classes . '" data-paged="' . $paged . '" data-pages-count="' . $pagesCount . '">' . $result . '</div>';
        }
        wp_reset_postdata();
        return $result;
    }