/**
         * Displays option page for importing and exporting options
         * @since 5.3.2
         */
        public static function settings_page()
        {
            $options = jm_tc_get_options();
            ?>

            <div class="metabox-holder">
                <div class="postbox inbl">
                    <h3><span><?php 
            _e('Export');
            ?>
</span></h3>

                    <div class="inside">
                        <form method="post">
                            <p><input type="hidden" name="action" value="export_settings"/></p>

                            <p>
                                <?php 
            wp_nonce_field('export_nonce', 'export_nonce');
            ?>
                                <?php 
            submit_button(__('Export'), 'primary', 'submit', false);
            ?>
                            </p>
                        </form>
                    </div>
                    <!-- .inside -->
                </div>
                <!-- .postbox -->
                <div class="postbox inbl">
                    <h3><span><?php 
            _e('Import');
            ?>
</span></h3>

                    <div class="inside">
                        <form method="post" enctype="multipart/form-data">
                            <p>
                                <input type="file" name="import_file"/>
                            </p>

                            <p>
                                <input type="hidden" name="action" value="import_settings"/>
                                <?php 
            wp_nonce_field('import_nonce', 'import_nonce');
            ?>
                                <?php 
            submit_button(__('Import'), 'primary', 'submit', false);
            ?>
                            </p>
                        </form>
                    </div>
                    <!-- .inside -->
                </div>
                <!-- .postbox -->
            </div><!-- .metabox-holder -->
        <?php 
        }
 /**
  * filter for robots.txt rules
  * @since 5.3.2
  * @return string
  */
 public static function robots_mod($output, $public)
 {
     $opts = jm_tc_get_options();
     if ($opts['twitterCardRobotsTxt'] == 'yes') {
         $output .= "User-agent: Twitterbot" . "\n";
         $output .= "Disallow: ";
     }
     return $output;
 }
 /**
  * filter for robots.txt rules
  * @since 5.3.2
  * @return string
  */
 public static function robots_mod($output, $public)
 {
     $opts = \jm_tc_get_options();
     if ('yes' === $opts['twitterCardRobotsTxt']) {
         $output .= 'User-agent: Twitterbot' . PHP_EOL;
         $output .= 'Disallow: ';
     }
     return $output;
 }
 /**
  * 6.1
  * Clean my mess
  */
 public static function danger_notice()
 {
     if (!current_user_can('install_plugins')) {
         return;
     }
     $options = \jm_tc_get_options();
     if ('tweetpressfr' === strtolower($options['twitterSite']) || 'tweetpressfr' === strtolower($options['twitterCreator'])) {
         printf(__('<div class="error"><p>Cards are broken because you use plugin\'s author account as Twitter site and /or Twitter Creator, please <a href="%s">change it here</a></p></div>'), esc_url(admin_url('admin.php?page=jm_tc')));
     }
 }
Exemplo n.º 5
0
 /**
  * Constructor
  * @since 5.3.2
  */
 public function __construct()
 {
     add_filter('robots_txt', array($this, 'robots_mod'));
     $this->opts = \jm_tc_get_options();
     if (isset($this->opts['twitterCardExcerpt']) && 'yes' === $this->opts['twitterCardExcerpt']) {
         add_filter('jm_tc_get_excerpt', array($this, 'modify_excerpt'));
     }
     add_action('wpmu_new_blog', array($this, 'new_blog'));
     add_filter('jm_tc_card_site', array($this, 'remove_tweetpressfr'));
     add_filter('jm_tc_card_creator', array($this, 'remove_tweetpressfr'));
 }
 /**
  * Init meta box
  */
 public static function initialize()
 {
     if (!class_exists('cmb_Meta_Box')) {
         require_once JM_TC_METABOX_DIR . 'init.php';
     }
     /* Thumbnails */
     $opts = jm_tc_get_options();
     $is_crop = true;
     $crop = $opts['twitterCardCrop'];
     $crop_x = $opts['twitterCardCropX'];
     $crop_y = $opts['twitterCardCropY'];
     $size = $opts['twitterCardImgSize'];
     switch ($crop) {
         case 'yes':
             $is_crop = true;
             break;
         case 'no':
             $is_crop = false;
             break;
         case 'yo':
             global $wp_version;
             $is_crop = version_compare($wp_version, '3.9', '>=') ? array($crop_x, $crop_y) : true;
             break;
     }
     if (function_exists('add_theme_support')) {
         add_theme_support('post-thumbnails');
     }
     switch ($size) {
         case 'small':
             add_image_size('jmtc-small-thumb', 280, 150, $is_crop);
             /* the minimum size possible for Twitter Cards */
             break;
         case 'web':
             add_image_size('jmtc-max-web-thumb', 435, 375, $is_crop);
             /* maximum web size for photo cards */
             break;
         case 'mobile-non-retina':
             add_image_size('jmtc-max-mobile-non-retina-thumb', 280, 375, $is_crop);
             /* maximum non retina mobile size for photo cards*/
             break;
         case 'mobile-retina':
             add_image_size('jmtc-max-mobile-retina-thumb', 560, 750, $is_crop);
             /* maximum retina mobile size for photo cards  */
             break;
         default:
             add_image_size('jmtc-small-thumb', 280, 150, $is_crop);
             /* the minimum size possible for Twitter Cards */
     }
 }
 /**
  * Constructor
  * @since 5.3.2
  */
 function __construct()
 {
     $this->opts = \jm_tc_get_options();
     //render
     add_action('cmb_render_text_number', array($this, 'render_text_number'), 10, 2);
     add_action('cmb_render_text_url_https', array($this, 'render_text_url_https'), 10, 2);
     //alter desc and preview attributes
     add_filter('cmb_title_attributes', array($this, 'cmb_update_title_description'), 10, 2);
     //register meta box
     add_action('cmb_meta_boxes', array($this, 'register_meta_boxes'), 10, 1);
     //show on/off field in post
     add_filter('cmb_show_on', array($this, 'exclude_from_post'), 10, 2);
     //show on/off field in profile
     add_filter('cmb_show_on', array($this, 'exclude_from_profile'), 10, 2);
 }
Exemplo n.º 8
0
 /**
  * @return string
  */
 static function thumbnail_sizes()
 {
     $opts = \jm_tc_get_options();
     $size = $opts['twitterCardImgSize'];
     switch ($size) {
         case 'small':
             return 'jmtc-small-thumb';
             break;
         case 'web':
             return 'jmtc-max-web-thumb';
             break;
         case 'mobile-non-retina':
             return 'jmtc-max-mobile-non-retina-thumb';
             break;
         case 'mobile-retina':
             return 'jmtc-max-mobile-retina-thumb';
             break;
         default:
             return 'jmtc-small-thumb';
     }
 }
        /**
         * get size setting and convert it into custom sizes
         * @since 5.3.2
         * @param integer $post_id
         * @return string
         */
        public static function thumbnail_sizes($post_id)
        {
            $opts = jm_tc_get_options();
            $size = $opts['twitterCardImgSize'];
            switch ($size) {
                case 'small':
                    $twitterCardImgSize = 'jmtc-small-thumb';
                    break;
                case 'web':
                    $twitterCardImgSize = 'jmtc-max-web-thumb';
                    break;
                case 'mobile-non-retina':
                    $twitterCardImgSize = 'jmtc-max-mobile-non-retina-thumb';
                    break;
                case 'mobile-retina':
                    $twitterCardImgSize = 'jmtc-max-mobile-retina-thumb';
                    break;
                default:
                    $twitterCardImgSize = 'jmtc-small-thumb';
                    ?>
<!-- @(-_-)] --><?php 
            }
            return $twitterCardImgSize;
        }
Exemplo n.º 10
0
 /**
  * Metabox constructor.
  */
 public function __construct()
 {
     add_filter('rwmb_meta_boxes', array($this, 'register_metaboxes'));
     add_filter('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     $this->opts = \jm_tc_get_options();
 }
Exemplo n.º 11
0
 public function __construct($post_ID)
 {
     $this->post_ID = $post_ID;
     $this->opts = \jm_tc_get_options();
 }
 /**
  * Constructor
  * @since 5.3.2
  */
 function __construct()
 {
     $this->opts = jm_tc_get_options();
 }
Exemplo n.º 13
0
 public function __construct(Admin\Options $options)
 {
     $this->options = $options;
     $this->opts = \jm_tc_get_options();
 }
    /**
     * Allows to show what could render the cards on Twitter
     *
     * @param $post_ID
     *
     * @return string
     */
    public static function show_preview($post_ID)
    {
        $GLOBALS['jm_twitter_cards']['options'] = new Options();
        $options = $GLOBALS['jm_twitter_cards']['options'];
        $opts = \jm_tc_get_options();
        $is_og = $opts['twitterCardOg'];
        /* most important meta */
        $cardType_arr = $options->card_type($post_ID);
        $creator_arr = $options->creator_username(true);
        $site_arr = $options->site_username();
        $title_arr = $options->title($post_ID);
        $description_arr = $options->description($post_ID);
        $img_arr = $options->image($post_ID);
        /* secondary meta */
        $player_arr = $options->player($post_ID);
        $deep_link_arr = $options->deep_linking();
        // default
        $app = '';
        $size = 16;
        $class = 'featured-image';
        $tag = 'img';
        $close_tag = '';
        $src = 'src';
        $product_meta = '';
        $styles = '';
        $position = 'position:relative;';
        $hide = '';
        $img = 'yes' === $is_og ? $img_arr['image'] : $img_arr['image:src'];
        $img_summary = '';
        $gallery_meta = '';
        // particular cases
        if (in_array('summary_large_image', $cardType_arr)) {
            $styles = 'width:100%;';
            $size = '100%';
        } elseif (in_array('photo', $cardType_arr)) {
            $styles = 'width:100%;';
            $size = '100%';
        } elseif (in_array('player', $cardType_arr)) {
            $styles = 'width:100%;';
            $img = 'yes' === $is_og ? $img_arr['image'] : $img_arr['image:src'];
            $src = 'controls poster';
            $tag = 'video';
            $close_tag = '</video>';
            $size = '100%';
        } elseif (in_array('summary', $cardType_arr)) {
            $styles = 'width: 60px; height: 60px; margin-left:.6em;';
            $size = 60;
            $hide = 'hide';
            $class = 'summary-image';
            $img_summary = '<img class="' . $class . '" width="' . $size . '" height="' . $size . '" style="' . $styles . ' -webkit-user-drag: none; " ' . $src . '="' . $img . '">';
            $float = 'float:right;';
        } elseif (in_array('app', $cardType_arr)) {
            $hide = 'hide';
            $class = 'bg-opacity';
            $app = '<div class="app-view" style="float:left;">';
            $app .= '<strong>' . __('Preview for app cards is not available yet.', 'jm-tc') . '</strong>';
            $app .= '</div>';
        } else {
            $styles = 'float:none;';
        }
        $output = '<div class="fake-twt">';
        $output .= $app;
        $output .= '<div class="e-content ' . $class . '">
							<div style="float:left;">
							' . get_avatar(false, 16) . '
							<span>' . __('Name associated with ', 'jm-tc') . $site_arr['site'] . '</span>

							<div style="float:left;" class="' . $hide . '">
								<' . $tag . ' class="' . $class . '" width="' . $size . '" height="' . $size . '" style="' . $styles . ' -webkit-user-drag: none; " ' . $src . '="' . $img . '">' . $close_tag . '
							
							' . $product_meta . '
							</div>
							</div>
							
							' . $gallery_meta . '
									
							<div style="float:left;">
							<div><strong>' . $title_arr['title'] . '</strong></div>
							<div><em>By ' . __('Name associated with ', 'jm-tc') . $creator_arr['creator'] . '</em></div>
							<div>' . $description_arr['description'] . '</div>
							</div>
							' . $img_summary . '<div style="float:left;" class="gray"><strong>' . __('View on the web', 'jm-tc') . '<strong></div></div></div>';
        $output .= '</div>';
        return $output;
    }
        /**
         * output cards preview
         * @return string
         * @param integer $post_ID
         */
        public static function show_preview($post_ID)
        {
            global $jm_twitter_cards;
            $jm_twitter_cards['options'] = new JM_TC_Options();
            $options = $jm_twitter_cards['options'];
            $opts = jm_tc_get_options();
            $is_og = $opts['twitterCardOg'];
            /* most important meta */
            $cardType_arr = $options->cardType($post_ID);
            $creator_arr = $options->creatorUsername(true);
            $site_arr = $options->siteUsername();
            $title_arr = $options->title($post_ID);
            $description_arr = $options->description($post_ID);
            $img_arr = $options->image($post_ID);
            /* secondary meta */
            $product_arr = $options->product($post_ID);
            $player_arr = $options->player($post_ID);
            $deep_link_arr = $options->deeplinking();
            // default
            $app = '';
            $size = 16;
            $class = 'featured-image';
            $tag = 'img';
            $close_tag = '';
            $src = 'src';
            $product_meta = '';
            $styles = '';
            $position = 'position:relative;';
            $hide = '';
            $img = $is_og == 'yes' ? $img_arr['image'] : $img_arr['image:src'];
            $img_summary = '';
            $gallery_meta = '';
            // particular cases
            if (in_array('summary_large_image', $cardType_arr)) {
                $styles = "width:100%;";
                $size = "100%";
            } elseif (in_array('photo', $cardType_arr)) {
                $styles = "width:100%;";
                $size = "100%";
            } elseif (in_array('player', $cardType_arr)) {
                $styles = "width:100%;";
                $img = $is_og == 'yes' ? $img_arr['image'] : $img_arr['image:src'];
                $src = "controls poster";
                $tag = "video";
                $close_tag = "</video>";
                $size = "100%";
            } elseif (in_array('gallery', $cardType_arr)) {
                $hide = 'hide';
                $gallery_meta = '<div class="gallery-meta-container">';
                if (is_array($img_arr)) {
                    $i = 0;
                    foreach ($img_arr as $name => $url) {
                        $gallery_meta .= '<img class="tile" src="' . $url . '" alt="" />';
                    }
                    $i++;
                    if ($i > 3) {
                        break;
                    }
                }
                $gallery_meta .= '</div>';
            } elseif (in_array('summary', $cardType_arr)) {
                $styles = 'width: 60px; height: 60px; margin-left:.6em;';
                $size = 60;
                $hide = 'hide';
                $class = 'summary-image';
                $img_summary = '<img class="' . $class . '" width="' . $size . '" height="' . $size . '" style="' . $styles . ' -webkit-user-drag: none; " ' . $src . '="' . $img . '">';
                $float = 'float:right;';
            } elseif (in_array('product', $cardType_arr)) {
                $product_meta = '<div class="product-view" style="position:relative;">';
                $product_meta .= '<span class="bigger"><strong>' . $product_arr['data1'] . '</strong></span>';
                $product_meta .= '<span>' . $product_arr['label1'] . '</span>';
                $product_meta .= '<span class="bigger"><strong>' . $product_arr['data2'] . '</strong></span>';
                $product_meta .= '<span>' . $product_arr['label2'] . '</span>';
                $product_meta .= '</div>';
                $styles = 'float:left; width: 120px; height: 120px; margin-right:.6em;';
                $size = 120;
            } elseif (in_array('app', $cardType_arr)) {
                $hide = 'hide';
                $class = 'bg-opacity';
                $app = '<div class="app-view" style="float:left;">';
                $app .= '<strong>' . __('Preview for app cards is not available yet.', 'jm-tc') . '</strong>';
                $app .= '</div>';
            } else {
                $styles = "float:none;";
            }
            $output = '<div class="fake-twt">';
            $output .= $app;
            $output .= '<div class="e-content ' . $class . '">
							<div style="float:left;">
							' . get_avatar(false, 16) . '
							
							<span>' . __('Name associated with ', 'jm-tc') . $site_arr['site'] . '</span>
							
							<div style="float:left;" class="' . $hide . '">
								<' . $tag . ' class="' . $class . '" width="' . $size . '" height="' . $size . '" style="' . $styles . ' -webkit-user-drag: none; " ' . $src . '="' . $img . '">' . $close_tag . '
							
							' . $product_meta . '
							</div>
							</div>
							
							' . $gallery_meta . '
									
							<div style="float:left;">
							<div><strong>' . $title_arr['title'] . '</strong></div>
							<div><em>By ' . __('Name associated with ', 'jm-tc') . $creator_arr['creator'] . '</em></div>
							<div>' . $description_arr['description'] . '</div>
							</div>
							' . $img_summary . '
							
							<div style="float:left;" class="gray"><strong>' . __('View on the web', 'jm-tc') . '<strong></div>
						
						</div></div>';
            $output .= '</div>';
            return $output;
        }
 /**
  * Displays option page for importing and exporting options
  * @since 5.3.2
  */
 public static function settings_page()
 {
     $options = \jm_tc_get_options();
     require JM_TC_DIR . 'views/settings.php';
 }