<div class="container-fluid">
    <div>
        <h3>Post Settings</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Settings</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Posts</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Post Settings</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Social Share Links</h6>
                    <div class="site-settings-alert"></div>
                    <form class="site-settings" method="POST">
                        <div class="float-left">
                            <label for="social_share_twitter" class="main-label">Twitter</label>
                            <br><small class="admin-info">Share posts to Twitter.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="social_share_twitter" value="0" />
                            <input type="checkbox" name="social_share_twitter" id="chck-social_share_twitter" value="1" <?php echo ($wo['config']['social_share_twitter'] == 1) ? 'checked': '';?>>
                            <label for="chck-social_share_twitter" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="social_share_facebook" class="main-label">Facebook</label>
                            <br><small class="admin-info">Share posts to Facebook.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="social_share_facebook" value="0" />
                            <input type="checkbox" name="social_share_facebook" id="chck-social_share_facebook" value="1" <?php echo ($wo['config']['social_share_facebook'] == 1) ? 'checked': '';?>>
                            <label for="chck-social_share_facebook" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="social_share_whatsup" class="main-label">What's app</label>
                            <br><small class="admin-info">Share posts to What's app.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="social_share_whatsup" value="0" />
                            <input type="checkbox" name="social_share_whatsup" id="chck-social_share_whatsup" value="1" <?php echo ($wo['config']['social_share_whatsup'] == 1) ? 'checked': '';?>>
                            <label for="chck-social_share_whatsup" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="social_share_pinterest" class="main-label">Pinterest</label>
                            <br><small class="admin-info">Share posts to Pinterest.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="social_share_pinterest" value="0" />
                            <input type="checkbox" name="social_share_pinterest" id="chck-social_share_pinterest" value="1" <?php echo ($wo['config']['social_share_pinterest'] == 1) ? 'checked': '';?>>
                            <label for="chck-social_share_pinterest" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        
                        <div class="float-left">
                            <label for="social_share_linkedin" class="main-label">Linkedin</label>
                            <br><small class="admin-info">Share posts to Linkedin.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="social_share_linkedin" value="0" />
                            <input type="checkbox" name="social_share_linkedin" id="chck-social_share_linkedin" value="1" <?php echo ($wo['config']['social_share_linkedin'] == 1) ? 'checked': '';?>>
                            <label for="chck-social_share_linkedin" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="social_share_telegram" class="main-label">Telegram</label>
                            <br><small class="admin-info">Share posts to Telegram.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="social_share_telegram" value="0" />
                            <input type="checkbox" name="social_share_telegram" id="chck-social_share_telegram" value="1" <?php echo ($wo['config']['social_share_telegram'] == 1) ? 'checked': '';?>>
                            <label for="chck-social_share_telegram" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                    </form>
                </div>
            </div>
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Adult Images Settings</h6>
                    <form class="adult-settings small-p" method="POST">
                        <div class="float-left">
                            <label for="adult_images" class="main-label">Adult Images Filtration</label>
                            <br><small class="admin-info">Enable this feature to blur or delete posts that contain adult contents using Google AI.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="adult_images" value="0" />
                            <input type="checkbox" name="adult_images" id="chck-adult_images" value="1" <?php echo ($wo['config']['adult_images'] == 1) ? 'checked': '';?>>
                            <label for="chck-adult_images" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <label for="adult_images_action">Action For Adult Images</label>
                        <select class="form-control show-tick" id="adult_images_action" name="adult_images_action">
                          <option value="0" <?php echo ($wo['config']['adult_images_action'] == '0')  ? ' selected': '';?>>Delete The Image</option>
                          <option value="1" <?php echo ($wo['config']['adult_images_action'] == '1')  ? ' selected': '';?>>Blur The Image</option>
                        </select>
                        <small class="admin-info">Choose the action to do once an adult image was found.</small>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Vision API key</label>
                                <input type="text" id="vision_api_key" name="vision_api_key" class="form-control" value="<?php echo $wo['config']['vision_api_key']?>">
                                <small class="admin-info">Your Google Vision API Key.</small>
                            </div>
                        </div>
                        <hr>
                        <p>Please follow the steps below to activate the system:</p> <hr>
                        <p class="main-label">1. Select or create a GCP project from <a href="https://console.cloud.google.com/projectcreate?previousPage=%2Fcloud-resource-manager%3F_ga%3D2.239227332.-679302599.1549629461&defaultProjectName=&project=robotic-subject-231114&folder=&organizationId=">Here</a></p>
                        <p class="main-label">2. Make sure that billing is enabled for your project <a href="https://cloud.google.com/billing/docs/how-to/modify-project">From Here</a> Or <a href="https://console.cloud.google.com/freetrial/signup/tos">Create a new billing account</a></p>
                        <p class="main-label">3. Enable the Cloud Vision API. <a href="https://console.cloud.google.com/flows/enableapi?apiid=vision-json.googleapis.com&_ga=2.132996809.-679302599.1549629461">From Here</a></p>
                        <p class="main-label">4. Create an API key:</p>
                        <p >     - Navigate to the <a href="https://console.cloud.google.com/apis/credentials?_ga=2.194723562.-679302599.1549629461">APIs & Services → Credentials</a> panel in GCP Console.</p>
                        <p>     - Select Create credentials, then select API key from the dropdown menu.</p>
                        <p>     - Click the Create button. The API key created dialog box displays your newly created key.</p>
                        
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <div class="adult-settings-test-alert"></div>
                        <div class="btn btn-info m-t-15 waves-effect" id="test_btn" onclick="Wo_TestVisionApi();">Test API</div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">General Posts & Comments Settings</h6>
                    <form class="site-settings2" method="POST">
                        <div class="float-left">
                            <label for="memories_system" class="main-label">Memories System</label>
                            <br><small class="admin-info">Show post memories for users, on a yearly basis.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="memories_system" value="0" />
                            <input type="checkbox" name="memories_system" id="chck-memories_system" value="1" <?php echo ($wo['config']['memories_system'] == 1) ? 'checked': '';?>>
                            <label for="chck-memories_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="watermark" class="main-label">Watermark Overlay</label>
                            <br><small class="admin-info">This feature will create an overlay watermark over images & videos. <br> The used icon path is: <?php echo "./themes/{$wo['config']['theme']}/img/icon.png";?></small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="watermark" value="0" />
                            <input type="checkbox" name="watermark" id="chck-watermark" value="1" <?php echo ($wo['config']['watermark'] == 1) ? 'checked': '';?>>
                            <label for="chck-watermark" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="shout_box_system" class="main-label">Shout Box System</label>
                            <br><small class="admin-info">Allow users to create posts anonymously.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="shout_box_system" value="0" />
                            <input type="checkbox" name="shout_box_system" id="chck-shout_box_system" value="1" <?php echo ($wo['config']['shout_box_system'] == 1) ? 'checked': '';?>>
                            <label for="chck-shout_box_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="colored_posts_system" class="main-label">Colored Posts</label>
                            <br><small class="admin-info">Users can create colored posts. <br> You can manage colored version from <a href="<?php echo Wo_LoadAdminLinkSettings('manage-colored-posts'); ?>">Manage Colored Posts</a></small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="colored_posts_system" value="0" />
                            <input type="checkbox" name="colored_posts_system" id="chck-colored_posts_system" value="1" <?php echo ($wo['config']['colored_posts_system'] == 1) ? 'checked': '';?>>
                            <label for="chck-colored_posts_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="post_approval" class="main-label">Post Approval System</label>
                            <br><small class="admin-info">The post will be sent to admins and moderators for approval before publishing.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="post_approval" value="0" />
                            <input type="checkbox" name="post_approval" id="chck-post_approval" value="1" <?php echo ($wo['config']['post_approval'] == 1) ? 'checked': '';?>>
                            <label for="chck-post_approval" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="popular_posts" class="main-label">Popular Posts & Comments</label>
                            <br><small class="admin-info">Show popular posts & comments this week. <br>When enabled, you can see the link in left sidebar on the home page.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="popular_posts" value="0" />
                            <input type="checkbox" name="popular_posts" id="chck-popular_posts" value="1" <?php echo ($wo['config']['popular_posts'] == 1) ? 'checked': '';?>>
                            <label for="chck-popular_posts" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>

                        <div class="float-left">
                            <label for="comment_reports" class="main-label">Comment Reports</label>
                            <br><small class="admin-info">Allow users to report comments.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="comment_reports" value="0" />
                            <input type="checkbox" name="comment_reports" id="chck-comment_reports" value="1" <?php echo ($wo['config']['comment_reports'] == 1) ? 'checked': '';?>>
                            <label for="chck-comment_reports" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        
                        <label for="maxCharacters">Max Allowed Characters Length</label>
                        <select class="form-control show-tick" id="maxCharacters" name="maxCharacters">
                          <option value="80"   <?php echo ($wo['config']['maxCharacters'] == 80) ? ' selected': '';?>>80 Characters</option>
                          <option value="160"  <?php echo ($wo['config']['maxCharacters'] == 160) ? ' selected': '';?>>160 Characters</option>
                          <option value="320"  <?php echo ($wo['config']['maxCharacters'] == 320) ? ' selected': '';?>>320 Characters</option>
                          <option value="640"  <?php echo ($wo['config']['maxCharacters'] == 640) ? ' selected': '';?>>640 Characters</option>
                          <option value="1280" <?php echo ($wo['config']['maxCharacters'] == 1280) ? ' selected': '';?>>1280 Characters</option>
                          <option value="5000" <?php echo ($wo['config']['maxCharacters'] == 5000) ? ' selected': '';?>>5000 Characters</option>
                          <option value="10000" <?php echo ($wo['config']['maxCharacters'] == 10000) ? ' selected': '';?>>Unlimited</option>
                        </select>
                        <small class="admin-info">Set the max allowed characters for posts, comments, replies and messages.</small>
                        <div class="clearfix"></div>
                        <hr>
                        <label class="form-check-label" for="order_posts_by">NewsFeed Posts</label>
                        <select class="form-control show-tick" id="order_posts_by" name="order_posts_by">
                            <option value="1" <?php echo ($wo['config']['order_posts_by'] == 1)   ? ' selected' : '';?> >Default (Show what user is following)</option>
                            <option value="0" <?php echo ($wo['config']['order_posts_by'] == 0)   ? ' selected' : '';?> >Show All Posts</option>
                        </select>
                        <small class="admin-info">Set how the newsfeed posts will appear for the users.</small>
                        <div class="clearfix"></div>
                        <hr>
                        <label class="form-check-label" for="second_post_button">Second Post Button</label>
                        <select class="form-control show-tick" id="second_post_button" name="second_post_button">
                          <option value="wonder" <?php echo ($wo['config']['second_post_button'] == 'wonder')   ? ' selected' : '';?> >Wonder</option>
                          <option value="dislike" <?php echo ($wo['config']['second_post_button'] == 'dislike')   ? ' selected' : '';?> >Dislike</option>
                          <option value="reaction" <?php echo ($wo['config']['second_post_button'] == 'reaction')   ? ' selected' : '';?> >Reaction System</option>
                          <option value="disabled" <?php echo ($wo['config']['second_post_button'] == 'disabled')   ? ' selected' : '';?> >Disable Button (just Like)</option>
                        </select>
                        <small class="admin-info">Choose what type of reaction you want to use beside the like button. You can manage reactions <a href="<?php echo Wo_LoadAdminLinkSettings('manage-reactions'); ?>">Here</a></small>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Post Limit Count</label>
                                <input type="text" id="post_limit" name="post_limit" class="form-control" value="<?php echo $wo['config']['post_limit']?>">
                                <small class="admin-info">How many posts a user can create in one hour?</small>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>


    </div>
    <!-- #END# Vertical Layout -->
<script>
function Wo_TestVisionApi() {
    $('#test_btn').text('Please wait..');
    $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=test_vision_api', function(data, textStatus, xhr) {
        if (data.status == 400) {
            $(".adult-settings-test-alert").html('<div class="alert alert-danger">' + data.message + '</div>');
            setTimeout(function (argument) {
                $(".adult-settings-test-alert").html('');
            },2000);
        }
        else{
            $(".adult-settings-test-alert").html('<div class="alert alert-success">' + data.message + '</div>');
            setTimeout(function (argument) {
                $(".adult-settings-test-alert").html('');
            },2000);
        }
        $('#test_btn').text('Test API');
    });
}
$(function() {
    $('.switcher input[type=checkbox]').click(function () {
        setToTrue = 0;
        if ($(this).is(":checked") === true) {
            setToTrue = 1;
        }
        var configName = $(this).attr('name');
        var hash_id = $('input[name=hash_id]').val();
        var objData = {};
        if (configName == 'redis') { 
            setToTrue = 'N';
            if ($(this).is(":checked") === true) {
              setToTrue = 'Y';
            }
        }
        objData[configName] = setToTrue;
        objData['hash_id'] = hash_id;
        $.post( Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_general_setting', objData);
    });

    var setTimeOutColor = setTimeout(function (){});
    $('select').on('change', function() {
         clearTimeout(setTimeOutColor);
        var thisElement = $(this);
        var configName = thisElement.attr('name');
        var hash_id = $('input[name=hash_id]').val();
        var objData = {};
        objData[configName] = this.value;
        objData['hash_id'] = hash_id;
        thisElement.addClass('warning');
        $.post( Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_general_setting', objData, function (data) {
            if (data.status == 200) {
                thisElement.removeClass('warning');
                thisElement.addClass('success');
            } else {
                thisElement.addClass('error');
            }
            var setTimeOutColor = setTimeout(function () {
                thisElement.removeClass('success');
                thisElement.removeClass('warning');
                thisElement.removeClass('error');
            }, 2000);
        });
    });
    $('input[type=text], input[type=number]').on('keyup', delay(function() {
            clearTimeout(setTimeOutColor);
            var thisElement = $(this);
            var configName = thisElement.attr('name');
            var hash_id = $('input[name=hash_id]').val();
            var objData = {};
            objData[configName] = this.value;
            objData['hash_id'] = hash_id;
            thisElement.addClass('warning');
            $.post( Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_general_setting', objData, function (data) {
                if (data.status == 200) {
                    thisElement.removeClass('warning');
                    thisElement.addClass('success');
                } else {
                    thisElement.addClass('error');
                }
                var setTimeOutColor = setTimeout(function () {
                    thisElement.removeClass('success');
                    thisElement.removeClass('warning');
                    thisElement.removeClass('error');
                }, 2000);
                //thisElement.focus();
            });
    }, 500));
});

</script>