function tonjoo_ecae_excerpt($content, $width, $justify)
{
    global $post;
    $options = get_option('tonjoo_ecae_options');
    $options = tonjoo_ecae_load_default($options);
    $postmeta = get_post_meta($post->ID, 'ecae_meta', true);
    if (function_exists('is_ecae_premium_exist') && isset($postmeta['disable_excerpt']) && $postmeta['disable_excerpt'] == 'yes') {
        return $content;
        exit;
    }
    $total_width = 0;
    $pos = strpos($content, '<!--more-->');
    $array_replace_list = array();
    // if read more
    if ($pos) {
        // check shortcode optons
        if ($options['strip_shortcode'] == 'yes') {
            $content = strip_shortcodes($content);
        }
        $content = substr($content, 0, $pos);
    } elseif ($post->post_excerpt != '') {
        // check shortcode optons
        if ($options['strip_shortcode'] == 'yes') {
            $content = strip_shortcodes($content);
        }
        $content = $post->post_excerpt;
    } elseif ($width == 0) {
        $content = '';
    } else {
        // Do caption shortcode
        $content = ecae_convert_caption($content, $options);
        $caption_image_replace = new eace_content_regex("|\$", "/<div[^>]*class=\"[^\"]*wp-caption[^\"]*\".*>(.*)<img[^>]+\\>(.*)<\\/div>/", $options, true);
        $figure_replace = new eace_content_regex("|:", "/<figure.*?\\>([^`]*?)<\\/figure>/", $options, true);
        $hyperlink_image_replace = new eace_content_regex("|#", "/<a[^>]*>(\n|\\s)*(<img[^>]+>)(\n|\\s)*<\\/a>/", $options, true);
        $image_replace = new eace_content_regex("|(", "/<img[^>]+\\>/", $options, true);
        //biggest -> lowest the change code
        $html_replace = array();
        $extra_markup = $options['extra_html_markup'];
        $extra_markup = trim($extra_markup);
        //prevent white space explode
        if ($extra_markup != '') {
            $extra_markup = explode('|', $extra_markup);
        } else {
            $extra_markup = array();
        }
        $extra_markup_tag = array('*=', '(=', ')=', '_=', '<=', '>=', '/=', '\\=', ']=', '[=', '{=', '}=', '|=');
        //default order
        $array_replace_list['pre'] = '=@';
        // syntax highlighter like crayon
        $array_replace_list['video'] = '=}';
        $array_replace_list['table'] = '={';
        $array_replace_list['p'] = '=!';
        $array_replace_list['b'] = '=&';
        $array_replace_list['a'] = '=*';
        $array_replace_list['i'] = '=)';
        $array_replace_list['h1'] = '=-';
        $array_replace_list['h2'] = '`=';
        $array_replace_list['h3'] = '!=';
        $array_replace_list['h4'] = '#=';
        $array_replace_list['h5'] = '$=';
        $array_replace_list['h6'] = '%=';
        $array_replace_list['ul'] = '=#';
        $array_replace_list['ol'] = '=$';
        $array_replace_list['strong'] = '=(';
        $array_replace_list['blockquote'] = '=^';
        foreach ($extra_markup as $markup) {
            $counter = 0;
            if (!isset($array_replace_list[$markup])) {
                $array_replace_list[$markup] = $extra_markup_tag[$counter];
            }
            $counter++;
        }
        //push every markup into processor
        foreach ($array_replace_list as $key => $value) {
            //use image processing algorithm for table and video
            if ($key == 'video' || $key == 'table') {
                $push = new eace_content_regex("{$value}", "/<{$key}.*?\\>([^`]*?)<\\/{$key}>/", $options, true);
            } else {
                $push = new eace_content_regex("{$value}", "/<{$key}.*?\\>([^`]*?)<\\/{$key}>/", $options);
            }
            array_push($html_replace, $push);
        }
        $pattern = get_shortcode_regex();
        if (!strpos('hana-flv-player', $pattern)) {
            $pattern = str_replace('embed', 'caption|hana-flv-player', $pattern);
        }
        $shortcode_replace = new eace_content_regex("+*", '/' . $pattern . '/s', $options);
        //trim image
        $option_image = $options['show_image'];
        if ($option_image == 'yes' || $option_image == 'first-image') {
            $number = false;
            //limit the image excerpt
            if ($option_image == 'first-image') {
                $number = 1;
            }
            $caption_image_replace->replace($content, $width, $number);
            $figure_replace->replace($content, $width, $number);
            $hyperlink_image_replace->replace($content, $width, $number);
            $image_replace->replace($content, $width, $number);
            // echo $content;
        } else {
            //remove image , this is also done for featured-image option
            $caption_image_replace->remove($content);
            $figure_replace->remove($content);
            $hyperlink_image_replace->remove($content);
            $image_replace->remove($content);
        }
        // check shortcode optons
        if ($options['strip_shortcode'] == 'yes') {
            $content = strip_shortcodes($content);
        }
        // Replace remaining tag
        foreach ($html_replace as $replace) {
            $replace->replace($content, $width, false, $total_width);
        }
        $shortcode_replace->replace($content, $width, false, $total_width);
        //use wp kses to fix broken element problem
        $content = wp_kses($content, array());
        if (strpos($content, '<!--STOP THE EXCERPT HERE-->') === false) {
            //give the stop mark so the plugin can stop
            $content = $content . '<!--STOP THE EXCERPT HERE-->';
        }
        //strip the text
        $content = substr($content, 0, strpos($content, '<!--STOP THE EXCERPT HERE-->'));
        //do the restore 3 times, avoid nesting
        $shortcode_replace->restore($content);
        foreach ($html_replace as $restore) {
            $restore->restore($content, $width);
        }
        foreach ($html_replace as $restore) {
            $restore->restore($content, $width);
        }
        foreach ($html_replace as $restore) {
            $restore->restore($content, $width);
        }
        $shortcode_replace->restore($content);
        /**
         * image position
         */
        switch ($options['image_position']) {
            case 'right':
                $img_position = "";
                break;
            case 'left':
                $img_position = "";
                break;
            case 'center':
                $img_position = "margin-left:auto !important; margin-right:auto !important;";
                break;
            case 'float-left':
                $img_position = "float:left;";
                break;
            case 'float-right':
                $img_position = "float:right;";
                break;
            default:
                $img_position = "text-align:left;";
                break;
        }
        $img_added_css = $img_position;
        if ($options['image_width_type'] == 'manual') {
            $img_added_css .= "width:{$options['image_width']}px;";
        }
        $img_added_css .= "padding:{$options['image_padding_top']}px {$options['image_padding_right']}px {$options['image_padding_bottom']}px {$options['image_padding_left']}px;";
        if ($option_image == 'yes') {
            $caption_image_replace->restore($content, false, true);
            $figure_replace->restore($content, false, true);
            $hyperlink_image_replace->restore($content, false, true);
            $image_replace->restore($content, false, true);
        } elseif ($option_image == 'first-image') {
            //catch all of hyperlink and image on the content => '|#'  and '|(' and '|$'
            preg_match_all('/\\|\\([0-9]*\\|\\(|\\|\\#[0-9]*\\|\\#|\\|\\$[0-9]*\\|\\$|\\|\\:[0-9]*\\|\\:/', $content, $result, PREG_PATTERN_ORDER);
            if (isset($result[0])) {
                $remaining = array_slice($result[0], 0, 1);
                if (isset($remaining[0])) {
                    //delete remaining image
                    $content = preg_replace('/\\|\\:[0-9]*\\|\\:/', '', $content);
                    $content = preg_replace('/\\|\\([0-9]*\\|\\C/', '', $content);
                    $content = preg_replace('/\\|\\#[0-9]*\\|\\#/', '', $content);
                    $content = preg_replace('/\\|\\$[0-9]*\\|\\$/', '', $content);
                    if ($options['image_position'] == 'left') {
                        $content = "<div class='ecae-image ecae-table-left'><div class='ecae-table-cell' style='{$img_added_css}'>" . $remaining[0] . "</div>" . "<div class='ecae-table-cell'>" . $content . '</div>';
                    } else {
                        if ($options['image_position'] == 'right') {
                            $content = "<div class='ecae-image ecae-table-right'><div class='ecae-table-cell' style='{$img_added_css}'>" . $remaining[0] . "</div>" . "<div class='ecae-table-cell'>" . $content . '</div>';
                        } else {
                            $content = "<div class='ecae-image' style='{$img_added_css}'>" . $remaining[0] . "</div>" . $content;
                        }
                    }
                    $caption_image_replace->restore($content, 1, true);
                    $figure_replace->restore($content, 1, true);
                    $hyperlink_image_replace->restore($content, 1, true);
                    $image_replace->restore($content, 1, true);
                }
            }
        } elseif ($option_image == 'featured-image') {
            //check featured image;
            $featured_image = has_post_thumbnail(get_the_ID());
            $image = false;
            if ($featured_image) {
                $image = get_the_post_thumbnail(get_the_ID());
            }
            // only put image if there is image :p
            if ($image) {
                if ($options['image_position'] == 'left') {
                    $content = "<div class='ecae-image ecae-table-left'><div class='ecae-table-cell' style='{$img_added_css}'>" . $image . "</div>" . "<div class='ecae-table-cell'>" . $content . '</div>';
                } else {
                    if ($options['image_position'] == 'right') {
                        $content = "<div class='ecae-image ecae-table-right'><div class='ecae-table-cell' style='{$img_added_css}'>" . $image . "</div>" . "<div class='ecae-table-cell'>" . $content . '</div>';
                    } else {
                        $content = "<div class='ecae-image' style='{$img_added_css}'>" . $image . "</div>" . $content;
                    }
                }
            }
        }
        // remove empty html tags
        if ($options["strip_empty_tags"] == 'yes') {
            $content = strip_empty_tags($content);
        }
        //delete remaining image
        $content = preg_replace('/\\|\\([0-9]*\\|\\C/', '', $content);
        $content = preg_replace('/\\|\\#[0-9]*\\|\\#/', '', $content);
        //delete remaining
        $extra_markup_tag = array('*=' . '(=', ')=', '_=', '<=', '>=', '/=', '\\=', ']=', '[=', '{=', '}=', '|=');
        foreach ($extra_markup_tag as $value) {
            $char = str_split($value);
            $content = preg_replace("/" . "\\" . "{$char[0]}" . "\\" . "{$char[1]}" . "[0-9]*" . "\\" . "{$char[0]}" . "\\" . "{$char[1]}" . "/", '', $content);
        }
        foreach ($array_replace_list as $key => $value) {
            $char = str_split($value);
            $content = preg_replace("/" . "\\" . "{$char[0]}" . "\\" . "{$char[1]}" . "[0-9]*" . "\\" . "{$char[0]}" . "\\" . "{$char[1]}" . "/", '', $content);
        }
    }
    /**
     * readmore text
     */
    $link = get_permalink();
    $readmore = "";
    $is_readmore = false;
    //remove last div is image position left / right
    if ($options['image_position'] == 'left' || $options['image_position'] == 'right' && strpos($content, 'ecae-table-cell')) {
        if (strpos($content, 'ecae-table-cell')) {
            $content = substr($content, 0, -6);
        }
    }
    if (trim($options['read_more']) != '-') {
        //failsafe
        $options['read_more_text_before'] = isset($options['read_more_text_before']) ? $options['read_more_text_before'] : '...';
        $button_skin = explode('-PREMIUM', $options['button_skin']);
        $trim_readmore_before = trim($options['read_more_text_before']);
        $read_more_text_before = empty($trim_readmore_before) ? $options['read_more_text_before'] : $options['read_more_text_before'] . "&nbsp;&nbsp;";
        $readmore_link = " <a class='ecae-link' href='{$link}'><span>{$options['read_more']}</span></a>";
        $readmore = "<p class='ecae-button {$button_skin[0]}' style='text-align:{$options['read_more_align']};' >{$read_more_text_before} {$readmore_link}</p>";
        // button_display_option
        if (!strpos($options['excerpt_method'], '-paragraph')) {
            if (strpos($content, '<!-- READ MORE TEXT -->')) {
                $is_readmore = true;
            }
            if ($options['button_display_option'] == 'always_show') {
                $content = str_replace('<!-- READ MORE TEXT -->', '', $content);
                $content = $content . $readmore;
            } else {
                if ($options['button_display_option'] == 'always_hide') {
                    $content = str_replace('<!-- READ MORE TEXT -->', '', $content);
                    $is_readmore = false;
                } else {
                    $content = str_replace('<!-- READ MORE TEXT -->', $readmore, $content);
                }
            }
        }
    }
    /**
     * filter if 1st-paragraph mode 
     */
    if (strpos($options['excerpt_method'], '-paragraph')) {
        $num_paragraph = substr($options['excerpt_method'], 0, 1);
        $content = get_per_paragraph(intval($num_paragraph), $content);
        global $content_pure;
        $len_content = strlen(wp_kses($content, array())) + 1;
        // 1 is a difference between them
        $len_content_pure = strlen(wp_kses($content_pure, array()));
        // button_display_option
        if ($options['button_display_option'] == 'always_show') {
            $content = $content . $readmore;
            $is_readmore = true;
        } else {
            if ($options['button_display_option'] == 'always_hide') {
                $content = $content;
            } else {
                if ($len_content < $len_content_pure) {
                    $content = $content . $readmore;
                    $is_readmore = true;
                }
            }
        }
    }
    // wrap with a container
    $justify = $justify != 'no' ? $justify : 'inherit';
    $content = "<div class='ecae' style='text-align:{$justify}'>" . $content . "</div>";
    //add last div is image position left / right
    if ($options['image_position'] == 'left' || $options['image_position'] == 'right') {
        if (strpos($content, 'ecae-table-cell')) {
            $content .= '</div>';
        }
    }
    /**
     * custom css
     */
    $style = "<style type='text/css'>";
    $trimmed_custom_css = str_replace(' ', '', $options["custom_css"]);
    if ($trimmed_custom_css != '') {
        $style .= $options["custom_css"];
    }
    if (function_exists('is_ecae_premium_exist') && isset($options["button_font_size"])) {
        $style .= '.ecae-button { font-size: ' . $options["button_font_size"] . 'px !important; }';
    }
    if ($is_readmore && $options['readmore_inline'] == 'yes') {
        $style .= ".ecae p:nth-last-of-type(2) {\n            display: inline !important;\n            padding-right: 10px;\n        }\n\n        .ecae-button {\n            display: inline-block !important;\n        }";
    }
    $style .= "</style>";
    // remove empty html tags
    if ($options["strip_empty_tags"] == 'yes') {
        $content = strip_empty_tags($content);
    }
    return "<!-- Generated by Easy Custom Auto Excerpt -->{$style} {$content}<!-- Generated by Easy Custom Auto Excerpt -->";
}
Exemplo n.º 2
0
/**
 * Create the options page
 */
function tonjoo_ecae_options_do_page()
{
    global $select_options, $radio_options;
    require_once plugin_dir_path(__FILE__) . 'walker_dropdown_multiple.php';
    if (!isset($_REQUEST['settings-updated'])) {
        $_REQUEST['settings-updated'] = false;
    }
    /**
     * Save options
     */
    if ($_POST && isset($_POST['tonjoo_ecae_options'])) {
        /**
         * Excerpt in page
         */
        $excerpt_in_page = isset($_POST['excerpt_in_page']) ? $_POST['excerpt_in_page'] : false;
        $excerpt_in_page_dump = '';
        if (is_array($excerpt_in_page)) {
            foreach ($excerpt_in_page as $key => $value) {
                $excerpt_in_page_dump .= $value . '|';
            }
        }
        $_POST['tonjoo_ecae_options']['excerpt_in_page'] = $excerpt_in_page_dump;
        /**
         * Advanced Post Page Excerpt
         */
        $_POST['tonjoo_ecae_options']['home_post_type'] = isset($_POST['home_post_type']) ? serialize($_POST['home_post_type']) : '';
        $_POST['tonjoo_ecae_options']['home_category'] = isset($_POST['home_category']) ? serialize($_POST['home_category']) : '';
        $_POST['tonjoo_ecae_options']['frontpage_post_type'] = isset($_POST['frontpage_post_type']) ? serialize($_POST['frontpage_post_type']) : '';
        $_POST['tonjoo_ecae_options']['frontpage_category'] = isset($_POST['frontpage_category']) ? serialize($_POST['frontpage_category']) : '';
        $_POST['tonjoo_ecae_options']['archive_post_type'] = isset($_POST['archive_post_type']) ? serialize($_POST['archive_post_type']) : '';
        $_POST['tonjoo_ecae_options']['archive_category'] = isset($_POST['archive_category']) ? serialize($_POST['archive_category']) : '';
        $_POST['tonjoo_ecae_options']['search_post_type'] = isset($_POST['search_post_type']) ? serialize($_POST['search_post_type']) : '';
        $_POST['tonjoo_ecae_options']['search_category'] = isset($_POST['search_category']) ? serialize($_POST['search_category']) : '';
        $_POST['tonjoo_ecae_options']['excerpt_in_page_advanced'] = isset($_POST['excerpt_in_page_advanced']) ? serialize($_POST['excerpt_in_page_advanced']) : '';
        $_POST['tonjoo_ecae_options']['advanced_page'] = isset($_POST['advanced_page']) ? serialize($_POST['advanced_page']) : '';
        $_POST['tonjoo_ecae_options']['page_post_type'] = isset($_POST['page_post_type']) ? serialize($_POST['page_post_type']) : '';
        $_POST['tonjoo_ecae_options']['page_category'] = isset($_POST['page_category']) ? serialize($_POST['page_category']) : '';
        /**
         * Tonjoo License
         */
        if (class_exists('TonjooPluginLicenseECAE')) {
            $PluginLicense = new TonjooPluginLicenseECAE($_POST['tonjoo_ecae_options']['license_key']);
            $_POST = $PluginLicense->license_on_save($_POST);
        }
        /**
         * Update options
         */
        update_option('tonjoo_ecae_options', $_POST['tonjoo_ecae_options']);
        /**
         * Redirect
         */
        $location = admin_url("options-general.php?page=tonjoo_excerpt") . '&settings-updated=true';
        echo "<meta http-equiv='refresh' content='0;url={$location}' />";
        echo "<h2>Loading...</h2>";
        exit;
    }
    if (!current_user_can('moderate_comments')) {
        wp_die('You do not have sufficient permissions to access this page.');
    }
    ?>

	<div class="wrap">
	<?php 
    echo "<h2>" . __("Easy Custom Auto Excerpt Options", TONJOO_ECAE) . "</h2>";
    ?>

	<br>
	<?php 
    _e("Easy Custom Auto Excerpt by", TONJOO_ECAE);
    ?>
 
	<a href='https://tonjoostudio.com' target="_blank">Tonjoo Studio</a> ~ 
	<a href='https://tonjoostudio.com/addons/easy-custom-auto-excerpt-premium/?utm_source=upgrade&utm_medium=link&utm_campaign=ecae' target="_blank"><?php 
    _e("Plugin Page", TONJOO_ECAE);
    ?>
</a> | 
	<a href='http://wordpress.org/support/view/plugin-reviews/easy-custom-auto-excerpt?filter=5' target="_blank"><?php 
    _e("Please Rate :)", TONJOO_ECAE);
    ?>
</a> |
	<a href='http://wordpress.org/extend/plugins/easy-custom-auto-excerpt/' target="_blank"><?php 
    _e("Comment", TONJOO_ECAE);
    ?>
</a> | 
	<a href='https://forum.tonjoostudio.com' target="_blank"><?php 
    _e("Bug Report", TONJOO_ECAE);
    ?>
</a> |
	<a href='https://tonjoostudio.com/addons/easy-custom-auto-excerpt/#faq' target="_blank"><?php 
    _e("FAQ", TONJOO_ECAE);
    ?>
</a>
	<br>
	<br>

	<?php 
    if (isset($_REQUEST['settings-updated']) && $_REQUEST['settings-updated'] == true) {
        ?>
	    <div id="message" class="updated">
	        <p><strong><?php 
        _e('Settings saved.', TONJOO_ECAE);
        ?>
</strong></p>
	    </div>
	<?php 
    }
    ?>

	<form method="post" action="">
		<?php 
    settings_fields('tonjoo_options');
    ?>
		<?php 
    $options = get_option('tonjoo_ecae_options');
    tonjoo_ecae_load_default($options);
    ?>

		<h2 class="nav-tab-wrapper">
			<a class="nav-tab" id='opt-general-tab' href='#opt-general'><?php 
    _e('General Options', TONJOO_ECAE);
    ?>
</a>
			<a class="nav-tab" id='opt-location-tab' href='#opt-location'><?php 
    _e('Excerpt Location', TONJOO_ECAE);
    ?>
</a>
			<a class="nav-tab" id='opt-readmore-tab' href='#opt-readmore'><?php 
    _e('Read More Button', TONJOO_ECAE);
    ?>
</a>
			
			<?php 
    if (class_exists('TonjooPluginLicenseECAE')) {
        ?>
			<a class="nav-tab" id='opt-license-tab' href='#opt-license'><?php 
        _e('License', TONJOO_ECAE);
        ?>
</a>
			<?php 
    }
    ?>
		</h2>

		<div class="metabox-holder columns-2" style="margin-right: 300px;">

		<!-- Extra style for options -->
		<style>
			.form-table td {
				vertical-align: middle;
			}

			.form-table th {
				width: 175px;
			}

			.form-table input[type=text], .form-table input[type=number], .form-table select {
				width: 200px;
				margin-right: 10px;
			}

			label.error{
			    margin-left: 5px;
			    color: red;
			}

			.form-table tr th {
			    text-align: left;
			    font-weight: normal;
			}

			.meta-subtitle {
			    margin: 0px -22px !important;
			    border-top:1px solid rgb(238, 238, 238);
			    background-color:#f6f6f6;
			}

			@media (max-width: 767px) {
			    .meta-subtitle {
			      margin-left: -12px !important;
			    }
			}

			label{
				vertical-align: top
			}
		</style>

		<!-- GENERAL OPTIONS -->
		<div id='opt-general' class="postbox-container group" style="width: 100%;min-width: 463px;float: left; ">
		<div class="meta-box-sortables ui-sortable">
		<div id="adminform" class="postbox">
		<h3 class="hndle"><span><?php 
    _e('General Excerpt Options', TONJOO_ECAE);
    ?>
</span></h3>
		<div class="inside" style="z-index:1;">
		<table class="form-table">
			<?php 
    require_once plugin_dir_path(__FILE__) . 'options-page-general.php';
    ?>
		</table>
		</div>
		</div>
		</div>
		</div>


		<!-- LOCATION OPTIONS -->
		<div id='opt-location' class="postbox-container group" style="width: 100%;min-width: 463px;float: left; ">
		<div class="meta-box-sortables ui-sortable">
		<div id="adminform" class="postbox">
		<h3 class="hndle"><span><?php 
    _e('Excerpt Location Options', TONJOO_ECAE);
    ?>
</span></h3>
		<div class="inside" style="z-index:1;">
		<table class="form-table">
			<?php 
    require_once plugin_dir_path(__FILE__) . 'options-page-location.php';
    ?>
		</table>
		</div>			
		</div>			
		</div>			
		</div>


		<!-- READMORE OPTIONS -->
		<div id='opt-readmore' class="postbox-container group" style="width: 100%;min-width: 463px;float: left; ">
		<div class="meta-box-sortables ui-sortable">
		<div id="adminform" class="postbox">
		<h3 class="hndle"><span><?php 
    _e('Read More Button', TONJOO_ECAE);
    ?>
</span></h3>
		<div class="inside" style="z-index:1;">
		<table class="form-table">
			<?php 
    require_once plugin_dir_path(__FILE__) . 'options-page-readmore.php';
    ?>
		</table>
		</div>			
		</div>			
		</div>			
		</div>

		<?php 
    if (class_exists('TonjooPluginLicenseECAE')) {
        ?>
		<!-- GENERAL OPTIONS -->
		<div id='opt-license' class="postbox-container group" style="width: 100%;min-width: 463px;float: left; ">
		<div class="meta-box-sortables ui-sortable">
		<div id="adminform" class="postbox">
		<h3 class="hndle"><span><?php 
        _e('License', TONJOO_ECAE);
        ?>
</span></h3>
		<div class="inside" style="z-index:1;">
		<table class="form-table">
			<?php 
        require_once plugin_dir_path(__FILE__) . 'options-license.php';
        ?>
		</table>
		</div>			
		</div>			
		</div>			
		</div>
		<?php 
    }
    ?>


		<!-- SIDEBAR -->
		<div class="postbox-container" style="float: right;margin-right: -300px;width: 280px;">
		<div class="metabox-holder" style="padding-top:0px;">	
		<div class="meta-box-sortables ui-sortable">
			<div id="email-signup" class="postbox">
				<h3 class="hndle"><span><?php 
    _e('Save Options', TONJOO_ECAE);
    ?>
</span></h3>
				<div class="inside" style="padding-top:10px;">
					<?php 
    _e('Save your changes to apply the options', TONJOO_ECAE);
    ?>
					<br>
					<br>
					<input type="submit" class="button-primary" value="<?php 
    _e('Save Options', TONJOO_ECAE);
    ?>
" />
					
				</div>
			</div>

			
			<!-- ADS -->
			<?php 
    $license = isset($options['license_status']) ? unserialize($options['license_status']) : false;
    if (!$license || !$license['status'] || !function_exists('is_ecae_premium_exist')) {
        ?>

			<div class="postbox">			
				<script type="text/javascript">
					/**
					 * Setiap dicopy-paste, yang find dan dirubah adalah
					 * - var pluginName
					 * - premium_exist
					 */

					jQuery(function(){					
						var pluginName = "ecae";
						var url = 'https://tonjoostudio.com/jsonp/?promo=get&plugin=' + pluginName;
						var promoFirst = new Array();
						var promoSecond = new Array();

						<?php 
        if (function_exists('is_ecae_premium_exist')) {
            ?>
						var url = 'https://tonjoostudio.com/jsonp/?promo=get&plugin=' + pluginName + '&premium=true';
						<?php 
        }
        ?>

						// strpos function
						function strpos(haystack, needle, offset) {
							var i = (haystack + '')
								.indexOf(needle, (offset || 0));
							return i === -1 ? false : i;
						}

						jQuery.ajax({url: url, dataType:'jsonp'}).done(function(data){
							
							if(typeof data =='object')
							{
								var fristImg, fristUrl;

							    // looping jsonp object
								jQuery.each(data, function(index, value){

									<?php 
        if (!function_exists('is_ecae_premium_exist')) {
            ?>

									fristImg = pluginName + '-premium-img';
									fristUrl = pluginName + '-premium-url';

									// promoFirst
									if(index == fristImg)
								    {
								    	promoFirst['img'] = value;
								    }

								    if(index == fristUrl)
								    {
								    	promoFirst['url'] = value;
								    }

								    <?php 
        } else {
            ?>

								    if(! fristImg)
								    {
								    	// promoFirst
										if(strpos(index, "-img"))
									    {
									    	promoFirst['img'] = value;

									    	fristImg = index;
									    }

									    if(strpos(index, "-url"))
									    {
									    	promoFirst['url'] = value;

									    	fristUrl = index;
									    }
								    }

								    <?php 
        }
        ?>

									// promoSecond
									if(strpos(index, "-img") && index != fristImg)
								    {
								    	promoSecond['img'] = value;
								    }

								    if(strpos(index, "-url") && index != fristUrl)
								    {
								    	promoSecond['url'] = value;
								    }
								});

								//promo_1
								jQuery("#promo_1 img").attr("src",promoFirst['img']);
								jQuery("#promo_1 a").attr("href",promoFirst['url']);

								//promo_2
								jQuery("#promo_2 img").attr("src",promoSecond['img']);
								jQuery("#promo_2 a").attr("href",promoSecond['url']);
							}
						});
					});
				</script>

				<!-- <h3 class="hndle"><span>This may interest you</span></h3> -->
				<div class="inside" style="margin: 23px 10px 6px 10px;">
					<div id="promo_1" style="text-align: center;padding-bottom:17px;">
						<a href="https://tonjoostudio.com" target="_blank">
							<img src="<?php 
        echo plugins_url(HSCOMMENT_DIR_NAME . "/assets/loading-big.gif");
        ?>
" width="100%" alt="Tonjoo Studio">
						</a>
					</div>
					<div id="promo_2" style="text-align: center;">
						<a href="https://tonjoostudio.com" target="_blank">
							<img src="<?php 
        echo plugins_url(HSCOMMENT_DIR_NAME . "/assets/loading-big.gif");
        ?>
" width="100%" alt="Tonjoo Studio">
						</a>
					</div>
				</div>
			</div>

			<?php 
    }
    ?>

		</div>
		</div>
		</div>	

		</div>
	</form>
</div>

<?php 
}