function settings_page()
    {
        global $wpsfigp_settings;
        $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general';
        ?>
		<div class="wrap">
			<div id="icon-options-general" class="icon32"></div>
			<h2><?php 
        _e('Intagrate Settings', 'instagrate-pro');
        ?>
</h2>

			<h2 class="nav-tab-wrapper">
				<?php 
        foreach ($wpsfigp_settings as $tab) {
            ?>
					<a href="?post_type=<?php 
            echo INSTAGRATEPRO_POST_TYPE;
            ?>
&page=<?php 
            echo $_GET['page'];
            ?>
&tab=<?php 
            echo $tab['section_id'];
            ?>
" class="nav-tab<?php 
            echo $active_tab == $tab['section_id'] ? ' nav-tab-active' : '';
            ?>
">
						<?php 
            echo $tab['section_title'];
            ?>
					</a>
				<?php 
        }
        ?>
			</h2>

			<form action="options.php" method="post">
				<?php 
        settings_fields(instagrate_pro()->settings->wpsf->get_option_group());
        ?>
				<?php 
        instagrate_pro()->settings->do_settings_sections(instagrate_pro()->settings->wpsf->get_option_group());
        ?>
				<p class="submit">
					<input type="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'instagrate-pro');
        ?>
" />
				</p>
			</form>

		</div>
	<?php 
    }
Example #2
0
 /**
  * Runs the upgrade check for the plugin
  *
  * @action admin_init
  */
 function upgrade_check()
 {
     $current_version = get_option($this->installed_key, false);
     if (false === $current_version) {
         add_option($this->installed_key, INSTAGRATEPRO_VERSION);
         return;
     }
     if (version_compare($current_version, INSTAGRATEPRO_VERSION, '!=')) {
         // Database upgrades
         instagrate_pro()->installer->install(true);
         // Load migrations
         $this->load_migrations($current_version);
         // Finally update the database version
         update_option($this->installed_key, INSTAGRATEPRO_VERSION);
     }
 }
Example #3
0
function igp_uninstall()
{
    global $wpdb;
    $images_table_name = instagrate_pro()->images->get_table_name();
    // Delete tables igp_images
    $wpdb->query("DROP TABLE IF EXISTS `{$images_table_name}`;");
    // Delete all meta for posts of type Intagrate
    $meta_table = $wpdb->prefix . 'postmeta';
    $post_table = $wpdb->prefix . 'posts';
    $post_type = INSTAGRATEPRO_POST_TYPE;
    $wpdb->query("DELETE FROM {$meta_table} WHERE post_id IN ( SELECT id FROM {$post_table} WHERE post_type = '{$post_type}')");
    // Delete posts of type instagrate_pro
    $wpdb->query("DELETE FROM {$post_table} WHERE post_type = '{$post_type}'");
    // Delete options settings, version and db version
    delete_option('igp_db_version');
    delete_option('pvw_igp_version');
    delete_option('igpsettings_settings');
}
Example #4
0
 /**
  * Install
  * - Reactivate schedules if not upgrade
  * - Create tables
  *
  * @param bool $upgrade
  */
 function install($upgrade = false)
 {
     // Reactivate schedules
     if (!$upgrade) {
         instagrate_pro()->scheduler->reactivate_schedules();
     }
     // Install Table(s)
     instagrate_pro()->images->create_table();
 }
Example #5
0
<?php

/**
 * UTF8 Changes to images table
 */
global $wpdb;
$table = instagrate_pro()->images->get_table_name();
$wpdb->query("\talter table {$table} change tags tags BLOB;");
$wpdb->query("alter table {$table} change tags tags text CHARACTER SET utf8;");
$wpdb->query("alter table {$table} change caption caption BLOB;");
$wpdb->query("alter table {$table} change caption caption text CHARACTER SET utf8;");
$wpdb->query("alter table {$table} change caption_clean caption_clean BLOB;");
$wpdb->query("alter table {$table} change caption_clean caption_clean text CHARACTER SET utf8;");
$wpdb->query("alter table {$table} change caption_clean_no_tags caption_clean_no_tags BLOB;");
$wpdb->query("alter table {$table} change caption_clean_no_tags caption_clean_no_tags text CHARACTER SET utf8;");
$wpdb->query("alter table {$table} change username username BLOB;");
$wpdb->query("alter table {$table} change username username text CHARACTER SET utf8; ");
$wpdb->query("alter table {$table} CHARACTER SET utf8;");
Example #6
0
<?php

/**
 * 1.7.6
 *
 * Make sure all existing accounts that use public_content are forced to be reauthed
 *
 */
$accounts = instagrate_pro()->accounts->get_accounts();
if (!isset($accounts) || !is_array($accounts)) {
    return;
}
foreach ($accounts as $key => $account) {
    $options = get_post_meta($key, '_instagrate_pro_settings', true);
    $stream = Instagrate_Pro_Helper::setting('instagram_images', 'recent', $options);
    if (!in_array($stream, array('recent', 'feed'))) {
        // Stream is using public_content
        $options['needs_reconnect'] = 1;
        update_post_meta($key, '_instagrate_pro_settings', $options);
    }
}
 /**
  * Plugin Updater
  *
  * @access private
  * @since  1.6
  * @return void
  */
 private function updater()
 {
     $license_key = instagrate_pro()->licenses->get_license_key();
     if ($license_key) {
         new SellwirePluginUpdater_3lM('https://app.sellwire.net/api/1/plugin', plugin_basename(INSTAGRATEPRO_PLUGIN_FILE), $license_key);
     }
 }
 /**
  * Setup the final data for the table
  *
  * @access public
  * @since  1.5
  * @uses   Instagrate_Pro_Image_Moderation_Table::get_columns()
  * @uses   WP_List_Table::get_sortable_columns()
  * @uses   Instagrate_Pro_Image_Moderation_Table::get_pagenum()
  * @uses   Instagrate_Pro_Image_Moderation_Table::get_total_customers()
  * @return void
  */
 public function prepare_items()
 {
     global $image_status;
     $image_status = isset($_REQUEST['image_status']) ? $_REQUEST['image_status'] : 'all';
     $columns = $this->get_columns();
     $hidden = array();
     // No hidden columns
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->process_bulk_action();
     $this->items = $this->image_data();
     $this->total = instagrate_pro()->images->moderation_images_total();
     $this->set_pagination_args(array('total_items' => $this->total, 'per_page' => $this->per_page, 'total_pages' => ceil($this->total / $this->per_page)));
 }
Example #9
0
 function ajax_send_install_data()
 {
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'instagrate_pro')) {
         return 0;
     }
     $response['error'] = true;
     $response['message'] = __('There was an error sending your email using wp_mail()', 'instagrate-pro');
     $email = instagrate_pro()->debug->send_install_data();
     if ($email) {
         $response['error'] = false;
         $response['message'] = __('Install data sent successfully. Please make sure you have raised an issue on the Support Forum. Without knowing the issue this file isn\'t much help on its own and will not be responded too.', 'instagrate-pro');
     }
     echo json_encode($response);
     die;
 }
 function ajax_process_manual_post()
 {
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'instagrate_pro')) {
         return 0;
     }
     if (!isset($_POST['post_id']) || !isset($_POST['frequency'])) {
         return 0;
     }
     $response['error'] = false;
     $response['message'] = '';
     $images = instagrate_pro()->controller->post_account($_POST['post_id'], 'manual');
     $response['stats'] = instagrate_pro()->accounts->account_stats($_POST['post_id']);
     $response['meta'] = 'Done';
     $response['images'] = $images;
     $msg = "No media posted";
     if (is_array($images)) {
         $count = sizeof($images);
         $image_txt = $count > 1 ? ' media items posted' : ' media item posted';
         $msg = $count . $image_txt;
     }
     $response['message'] = $msg;
     echo json_encode($response);
     die;
 }
Example #11
0
        // Insert post
        $new_post = array('post_title' => $wp_post_title, 'post_content' => $wp_post_content, 'post_status' => 'publish', 'post_type' => 'instagrate_pro');
        $new_post_id = wp_insert_post($new_post);
        // Add post meta
        update_post_meta($new_post_id, '_instagrate_pro_settings', $new_account_meta);
        // Run change stream to get images
        $tags = $old_options[$tag . '_hashtag'];
        if ($tags != '') {
            $tags = str_replace(' ', '', $tags);
            $tags = str_replace('#', '', $tags);
            $tags = str_replace(',', '', $tags);
        }
        $images = instagrate_pro()->accounts->change_stream($new_post_id, $stream, $tags, $tags, '', '', 'posted');
        // Set schedule if needed
        if ($frequency == 'schedule') {
            instagrate_pro()->scheduler->set_schedule($new_post_id, $new_day, $new_time, 'igp_' . $schedule);
        }
    }
}
// Convert meta for lat long
$table = $wpdb->prefix . 'postmeta';
$wpdb->query("UPDATE {$table} SET meta_key = '_igp_latlon' WHERE meta_key = 'igp_latlon'");
// Delete ig image id meta
$table = $wpdb->prefix . 'postmeta';
$wpdb->query("DELETE FROM {$table} WHERE meta_key IN ('instagrate_id', 'instagrate_image_id')");
// Uninstall of old plugin
//remove schedule hooks
if (wp_next_scheduled('hourly_listen')) {
    wp_clear_scheduled_hook('hourly_listen');
}
if (wp_next_scheduled('twicedaily_listen')) {
 /**
  * Reactivate all schedules for all accounts
  */
 public function reactivate_schedules()
 {
     $accounts = instagrate_pro()->accounts->get_accounts();
     if (isset($accounts) && $accounts) {
         foreach ($accounts as $key => $account) {
             $account_settings = get_post_meta($key, '_instagrate_pro_settings', true);
             if (Instagrate_Pro_Helper::setting('posting_frequency', 'constant', $account_settings) == 'schedule') {
                 $schedule = Instagrate_Pro_Helper::setting('posting_schedule', 'igp_daily', $account_settings);
                 $new_day = $this->schedule_no_day($schedule) ? '' : Instagrate_Pro_Helper::setting('posting_day', '', $account_settings);
                 $new_time = Instagrate_Pro_Helper::setting('posting_time', date('H:00', strtotime('+1 hour')), $account_settings);
                 $this->set_schedule($key, $new_day, $new_time, $schedule);
             }
         }
     }
 }
     /**
      * Generates the HTML output of the settings fields
      *
      * @param array callback args from add_settings_field()
      */
     function generate_setting($args)
     {
         $section = $args['section'];
         $defaults = array('id' => 'default_field', 'title' => 'Default Field', 'desc' => '', 'std' => '', 'type' => 'text', 'choices' => array(), 'class' => '');
         $defaults = apply_filters('wpsf_defaults', $defaults);
         extract(wp_parse_args($args['field'], $defaults));
         $options = get_option($this->option_group . '_settings');
         $el_id = $this->option_group . '_' . $section['section_id'] . '_' . $id;
         $val = isset($options[$el_id]) ? $options[$el_id] : $std;
         do_action('wpsf_before_field');
         do_action('wpsf_before_field_' . $el_id);
         switch ($type) {
             case 'text':
                 $val = esc_attr(stripslashes($val));
                 echo '<input type="text" name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '" value="' . $val . '" class="regular-text ' . $class . '" />';
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 break;
             case 'textarea':
                 $val = esc_html(stripslashes($val));
                 echo '<textarea name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '" rows="5" cols="60" class="' . $class . '">' . $val . '</textarea>';
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 break;
             case 'select':
                 $val = esc_html(esc_attr($val));
                 echo '<select name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '" class="' . $class . '">';
                 foreach ($choices as $ckey => $cval) {
                     echo '<option value="' . $ckey . '"' . ($ckey == $val ? ' selected="selected"' : '') . '>' . $cval . '</option>';
                 }
                 echo '</select>';
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 break;
             case 'radio':
                 $val = esc_html(esc_attr($val));
                 foreach ($choices as $ckey => $cval) {
                     echo '<label><input type="radio" name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '_' . $ckey . '" value="' . $ckey . '" class="' . $class . '"' . ($ckey == $val ? ' checked="checked"' : '') . ' /> ' . $cval . '</label><br />';
                 }
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 break;
             case 'checkbox':
                 $val = esc_attr(stripslashes($val));
                 echo '<input type="hidden" name="' . $this->option_group . '_settings[' . $el_id . ']" value="0" />';
                 echo '<label><input type="checkbox" name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '" value="1" class="' . $class . '"' . ($val ? ' checked="checked"' : '') . ' /> ' . $desc . '</label>';
                 break;
             case 'checkboxes':
                 foreach ($choices as $ckey => $cval) {
                     $val = '';
                     if (isset($options[$el_id . '-' . $ckey])) {
                         $val = $options[$el_id . '-' . $ckey];
                     } elseif (is_array($std) && in_array($ckey, $std)) {
                         $val = $ckey;
                     }
                     $val = esc_html(esc_attr($val));
                     echo '<input type="hidden" name="' . $this->option_group . '_settings[' . $el_id . '-' . $ckey . ']" value="0" />';
                     echo '<label><input type="checkbox" name="' . $this->option_group . '_settings[' . $el_id . '-' . $ckey . ']" id="' . $el_id . '_' . $ckey . '" value="' . $ckey . '" class="' . $class . '"' . ($ckey == $val ? ' checked="checked"' : '') . ' /> ' . $cval . '</label><br />';
                 }
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 break;
             case 'color':
                 $val = esc_attr(stripslashes($val));
                 echo '<div style="position:relative;">';
                 echo '<input type="text" name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '" value="' . $val . '" class="' . $class . '" />';
                 echo '<div id="' . $el_id . '_cp" style="position:absolute;top:0;left:190px;background:#fff;z-index:9999;"></div>';
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 echo '<script type="text/javascript">
 		        jQuery(document).ready(function($){ 
                     var colorPicker = $("#' . $el_id . '_cp");
                     colorPicker.farbtastic("#' . $el_id . '");
                     colorPicker.hide();
                     $("#' . $el_id . '").live("focus", function(){
                         colorPicker.show();
                     });
                     $("#' . $el_id . '").live("blur", function(){
                         colorPicker.hide();
                         if($(this).val() == "") $(this).val("#");
                     });
                 });
                 </script></div>';
                 break;
             case 'file':
                 $val = esc_attr($val);
                 echo '<input type="text" name="' . $this->option_group . '_settings[' . $el_id . ']" id="' . $el_id . '" value="' . $val . '" class="regular-text ' . $class . '" /> ';
                 echo '<input type="button" class="button wpsf-browse" id="' . $el_id . '_button" value="Browse" />';
                 echo '<script type="text/javascript">
                 jQuery(document).ready(function($){
             		$("#' . $el_id . '_button").click(function() {
             			tb_show("", "media-upload.php?post_id=0&amp;type=image&amp;TB_iframe=true");
             			window.original_send_to_editor = window.send_to_editor;
                     	window.send_to_editor = function(html) {
                     		var imgurl = $("img",html).attr("src");
                     		$("#' . $el_id . '").val(imgurl);
                     		tb_remove();
                     		window.send_to_editor = window.original_send_to_editor;
                     	};
             			return false;
             		});
                 });
                 </script>';
                 break;
             case 'editor':
                 wp_editor($val, $el_id, array('textarea_name' => $this->option_group . '_settings[' . $el_id . ']'));
                 if ($desc) {
                     echo '<p class="description">' . $desc . '</p>';
                 }
                 break;
             case 'custom':
                 echo $std;
                 break;
             case 'license':
                 $key = isset($options[$el_id . '-key']) ? $options[$el_id . '-key'] : '';
                 $key = esc_attr(stripslashes($key));
                 $status = isset($options[$el_id . '-status']) ? $options[$el_id . '-status'] : false;
                 $status = esc_attr(stripslashes($status));
                 echo '<div id="igp_license">';
                 echo '<input type="hidden" name="' . $this->option_group . '_settings[' . $el_id . '-status]" value="' . $status . '">';
                 if ($status !== false && $status == 'activated') {
                     echo '<input type="hidden" name="' . $this->option_group . '_settings[' . $el_id . '-key]" value="' . $key . '">';
                     echo '<span style="color:green;">' . __('Active: ', 'instagrate-pro') . '</span>';
                     echo '<span class="regular-text">' . $key . '</span><br>  ';
                     echo '<input id="deactivate-license" type="button" class="button-secondary" value="' . __('Deactivate License', 'instagrate-pro') . '"/>';
                 } else {
                     if (instagrate_pro()->licenses->is_license_constant()) {
                         $license_key = instagrate_pro()->licenses->get_license_key($options);
                         echo '<input type="hidden" name="' . $this->option_group . '_settings[' . $el_id . '-key]" value="' . $license_key . '">';
                         echo '<span class="regular-text">' . $license_key . '</span><br>  ';
                         echo '<p class="description">' . __('Activate this license to enable automatic upgrades', 'instagrate-pro') . '</p>';
                     } else {
                         echo '<input type="text" name="' . $this->option_group . '_settings[' . $el_id . '-key]" id="' . $el_id . '-key" value="' . $key . '" class="regular-text ' . $class . '" />';
                         echo '<p class="description">' . __('Enter a valid license key to enable automatic upgrades', 'instagrate-pro') . '</p>';
                     }
                     echo '<input id="activate-license" type="button" class="button-primary" value="' . __('Activate License', 'instagrate-pro') . '"/>';
                 }
                 echo '<span class="spinner"></span></div>';
                 break;
             default:
                 break;
         }
         do_action('wpsf_after_field');
         do_action('wpsf_after_field_' . $el_id);
     }
Example #14
0
 /**
  * Checks if some content has the map shortcodes
  *
  * @param $content
  *
  * @return bool
  */
 public function has_map_shortcode($content)
 {
     $shortcodes = array('igp_map', 'igp_multimap', 'igp_get_map');
     foreach ($shortcodes as $shortcode) {
         if (instagrate_pro()->helper->has_shortcode($content, $shortcode)) {
             return true;
         }
     }
     return false;
 }
    function custom_columns($column)
    {
        // todo default value
        // todo get images key
        // get location name
        global $post;
        $options = get_post_meta($post->ID, '_instagrate_pro_settings', true);
        $profile_src = INSTAGRATEPRO_PLUGIN_URL . 'assets/img/not-connected.png';
        $profile_name = 'Not connected';
        if (Instagrate_Pro_Helper::setting('token', '', $options) != '') {
            $profile_name = $options['username'];
        }
        if (Instagrate_Pro_Helper::setting('user_thumb', '', $options) != '') {
            $profile_src = $options['user_thumb'];
        }
        $edit_url = get_admin_url() . 'post.php?post=' . $post->ID . '&amp;action=edit';
        switch ($column) {
            case 'profile-img':
                ?>
				<a href="<?php 
                echo $edit_url;
                ?>
">
					<img src="<?php 
                echo $profile_src;
                ?>
" width="30" height="30" alt="<?php 
                echo $profile_name;
                ?>
">
				</a>
				<?php 
                break;
            case 'profile':
                ?>
				<strong>
					<a href="<?php 
                echo $edit_url;
                ?>
" title="Edit Account">
						<?php 
                echo $profile_name;
                ?>
					</a>
				</strong>
				<br />
				<?php 
                echo instagrate_pro()->accounts->get_images_key($post->ID, true);
                break;
            case 'images':
                $posting = Instagrate_Pro_Helper::setting('instagram_images', '', $options);
                if ($posting == '') {
                    $posting_text = __('Not configured', 'instagrate-pro');
                } else {
                    $posting_text = ucfirst($posting) . __(' Media', 'instagrate-pro');
                    if ($posting == 'users' && Instagrate_Pro_Helper::setting('instagram_user', '', $options) != '' && Instagrate_Pro_Helper::setting('instagram_users_id', '', $options) != '') {
                        $posting_text .= '<br/>' . __('User', 'instagrate-pro') . ': <strong>' . Instagrate_Pro_Helper::setting('instagram_user', '', $options) . '</strong>';
                    }
                    if ($posting == 'location' && Instagrate_Pro_Helper::setting('instagram_location', '', $options) != '' && Instagrate_Pro_Helper::setting('instagram_location_id', '', $options) != '') {
                        $posting_text .= '<br/><strong>' . instagrate_pro()->accounts->get_location_name($post->ID, Instagrate_Pro_Helper::setting('instagram_location_id', '', $options)) . '</strong>';
                    }
                    $filter = Instagrate_Pro_Helper::setting('instagram_hashtags', '', $options);
                    if ($filter != '') {
                        $posting_text .= '<br/>' . __('Filter', 'instagrate-pro') . ': <strong>' . $filter . '</strong>';
                    }
                }
                echo $posting_text;
                break;
            case 'frequency':
                $frequency = Instagrate_Pro_Helper::setting('posting_frequency', 'constant', $options);
                $frequency = ucfirst($frequency);
                if ($frequency == 'Schedule') {
                    $frequency .= ' - ' . instagrate_pro()->scheduler->get_all_schedules(Instagrate_Pro_Helper::setting('posting_schedule', 'igp_daily', $options));
                    $frequency .= '<br/><div class="curtime"><span id="timestamp">' . __('Next', 'instagrate-pro') . ': <b>' . instagrate_pro()->scheduler->get_next_schedule($post->ID, Instagrate_Pro_Helper::setting('posting_schedule', 'igp_daily', $options)) . '</b></span></div>';
                }
                echo $frequency;
                break;
            case 'multiple-images':
                $multiple = Instagrate_Pro_Helper::setting('posting_multiple', 'each', $options);
                switch ($multiple) {
                    case 'each':
                        $multiple_text = __('Post Per Media', 'instagrate-pro');
                        break;
                    case 'group':
                        $multiple_text = __('Media Grouped', 'instagrate-pro');
                        break;
                    case 'single':
                        $type = Instagrate_Pro_Helper::setting('post_type', 'post', $options);
                        $same_post = Instagrate_Pro_Helper::setting('posting_same_post', '', $options);
                        if ($same_post != '') {
                            $same_post = get_post($same_post);
                            $same_post = $same_post->post_title;
                            $same_post = '<br/><strong>' . $same_post . '</strong>';
                        }
                        $multiple_text = __('Same', 'instagrate-pro') . ' ' . ucfirst($type) . $same_post;
                        break;
                }
                echo $multiple_text;
                break;
            case 'imagesaving':
                $feat = Instagrate_Pro_Helper::setting('post_featured_image', 'off', $options) == 'on' ? '<br/>Featured Image' : '';
                $saving = Instagrate_Pro_Helper::setting('post_save_media', 'off', $options) == 'on' ? __('Media Library', 'instagrate-pro') . $feat : __('Instagram Media', 'instagrate-pro');
                echo $saving;
                break;
            case 'classification':
                $tax = Instagrate_Pro_Helper::setting('post_taxonomy', '0', $options) != '0' ? ucwords(Instagrate_Pro_Helper::setting('post_taxonomy', '0', $options)) : '';
                if ($tax != '') {
                    $terms = Instagrate_Pro_Helper::setting('post_term', array(), $options);
                    if (!is_array($terms)) {
                        $terms = (array) $terms;
                    }
                    $term_text = '';
                    if ($terms && count($terms) > 0) {
                        foreach ($terms as $term_selected) {
                            $term_add = get_term($term_selected, Instagrate_Pro_Helper::setting('post_taxonomy', '0', $options));
                            if (!is_wp_error($term_add)) {
                                $term_text .= $term_add->name . ', ';
                            }
                        }
                        if (substr($term_text, -2) == ', ') {
                            $term_text = substr($term_text, 0, -2);
                        }
                    } else {
                        $term_text = 'Not Selected';
                    }
                    echo __('Taxonomy', 'instagrate-pro') . ': <strong>' . $tax . '</strong><br/>' . __('Terms', 'instagrate-pro') . ': <strong>' . $term_text . '</strong>';
                } else {
                    _e('None', 'instagrate-pro');
                }
                break;
            case 'type':
                $type = Instagrate_Pro_Helper::setting('post_type', 'post', $options);
                echo ucfirst($type);
                break;
            case 'status':
                $type = Instagrate_Pro_Helper::setting('post_status', 'publish', $options);
                echo ucfirst($type);
                break;
            case 'igp-actions':
                $actions = '<a class="igp-duplicate" title="Duplicate Account" rel="' . $post->ID . '" href="#">Duplicate</a>';
                $actions .= '<p><strong>Sync:</strong></p>';
                $actions .= '<a class="igp-sync-likes" title="Sync Likes" rel="' . $post->ID . '" href="#">Likes</a>';
                if (Instagrate_Pro_Helper::setting('igpsettings_comments_enable-comments', '0') == 1) {
                    $actions .= ' | <a class="igp-sync-comments" title="Sync Comments" rel="' . $post->ID . '" href="#">Comments</a>';
                }
                echo $actions;
                break;
        }
    }
Example #16
0
    public function show_notices()
    {
        global $post;
        if (isset($post->post_type) && $post->post_type == INSTAGRATEPRO_POST_TYPE || isset($_GET['page']) && $_GET['page'] == 'instagrate-pro-settings') {
            // Duplicate Account
            if (isset($_GET['message']) && $_GET['message'] == '14') {
                echo '<div class="updated">
							<p>' . __('Account duplicated') . ' </p>
						</div>';
            }
            // Likes Synced Account
            if (isset($_GET['message']) && $_GET['message'] == '15') {
                echo '<div class="updated">
							<p>' . __('Likes have been synced for this account successfully') . ' </p>
						</div>';
            }
            // Comments Synced Account
            if (isset($_GET['message']) && $_GET['message'] == '16') {
                echo '<div class="updated">
							<p>' . __('Comments have been synced for this account successfully') . ' </p>
						</div>';
            }
            // Display check for user to make sure a blog page is selected
            if ('page' == get_option('show_on_front')) {
                if (0 == get_option('page_for_posts')) {
                    $link_text = __('Settings -> Reading', 'instagrate-pro');
                    $link = '<a href="' . get_admin_url() . 'options-reading.php">' . $link_text . '</a>';
                    echo '<div class="updated">
							<p>' . __('You must select a page to display your posts in ', 'instagrate-pro') . $link . ' </p>
						</div>';
                }
            }
            // Display check to make sure there is write permissions on the debug file
            $debug_mode = Instagrate_Pro_Helper::setting('igpsettings_support_debug-mode', '0');
            $debug_file = INSTAGRATEPRO_PLUGIN_DIR . 'debug.txt';
            $file = file_exists($debug_file);
            if ($debug_mode == 1 && $file) {
                $write = instagrate_pro()->debug->can_write($debug_file);
                if ($write == false) {
                    $link_text = __('file', 'instagrate-pro');
                    $link = ' <a href="' . plugin_dir_url(INSTAGRATEPRO_PLUGIN_FILE) . 'debug.txt">debug.txt ' . $link_text . '</a>';
                    echo '<div class="error">
							<p>' . __('Debug mode is turned on. However, the debug file in the plugin folder is not writeable. Please contact your web hosting provider to amend the permissions on the', 'instagrate-pro') . $link . '</p>
						  </div>';
                }
            }
            // Instagram API Check
            $check = array();
            $check = instagrate_pro()->instagram->instagram_api_check();
            if ($check[0] == 0) {
                echo '<div class="error"><p>' . $check[1] . '</p></div>';
            }
            // Account Error Message
            if (isset($_GET['post']) && isset($_GET['action']) && $_GET['action'] == 'edit') {
                $account_settings = get_post_meta($post->ID, '_instagrate_pro_settings', true);
                $settings = (object) $account_settings;
                if (isset($settings->ig_error) && $settings->ig_error != '') {
                    echo '<div class="error"><p>' . $settings->ig_error . '</p></div>';
                }
            }
            // Auto Draft Warning Message
            if (isset($_GET['post_type']) && $_GET['post_type'] == 'instagrate_pro') {
                if (isset($post->post_status) && $post->post_status == 'auto-draft') {
                    echo '<div class="updated"><p>' . __('You must save the draft of this account before authorising with Instagram', 'instagrate-pro') . '</p></div>';
                }
            }
            // Safe mode for execution time
            if (ini_get('safe_mode') && ini_get('max_execution_time') != 0) {
                echo '<div class="updated">
							<p>' . sprintf(__("%sSafe mode%s is enabled on your server, so the PHP time and memory limits cannot be set by this plugin.\n\t\t\t\t\t\t\t\t\t\t\t\tYour time limit is %s seconds and your memory limit is %s, so if your accounts are posting lots of images at a time and saving them to the WordPress Media Library this may exceed the execution time. Each host has different methods available to increase these settings and a quick Google search should\n\t\t\t\t\t\t\t\t\t\t\t\tyield some information. If not, please contact your host for help.\n\t\t\t\t\t\t\t\t\t\t\t\tIf you cannot find an answer, please feel free to post a new topic.", 'instagrate-pro'), '<a href="http://php.net/manual/en/features.safe-mode.php"><strong>', '</a></strong>', ini_get('max_execution_time'), ini_get('memory_limit'), '</a>') . ' </p>
						</div>';
            }
        }
    }
Example #17
0
        $images = instagrate_pro()->images->get_images($key, 'posted');
        if (isset($images) && $images) {
            foreach ($images as $image) {
                // Set up template tags for title
                $this->template_caption = $image->caption_clean;
                $this->template_caption_tags_no_hash = str_replace('#', '', $image->caption_clean);
                $this->template_caption_no_tags = $image->caption_clean_no_tags;
                $this->template_tags = implode(apply_filters('igp_tag_sep', ' '), unserialize($image->tags));
                $image_tags = unserialize($image->tags);
                $this->template_tags_first = reset($image_tags);
                $this->template_username = $image->username;
                $this->template_date = date('M d, Y @ H:i', instagrate_pro()->helper->get_instagram_time($image->image_timestamp));
                $this->template_filter = $image->filter;
                $this->template_location_name = $image->location_name;
                $this->template_location_lat = $image->latitude;
                $this->template_location_lng = $image->longitude;
                // Template tags for title
                $template_tags = instagrate_pro()->tags->get_template_tags('title');
                // Custom title
                $wp_post_title = instagrate_pro()->tags->replace_template_tags($title_template, $template_tags, 'migrate_one_two');
                $post_table = $wpdb->prefix . 'posts';
                $querystr = $wpdb->prepare("\tSELECT ID\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$post_table}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE post_title = %s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND post_status = 'publish' ", $wp_post_title);
                $posts = $wpdb->get_results($querystr, OBJECT);
                foreach ($posts as $post) {
                    update_post_meta($post->ID, '_igp_id', $image->id);
                    update_post_meta($post->ID, 'ig_likes', $image->likes_count);
                }
            }
        }
    }
}
Example #18
0
 function ajax_sync_all_comments_likes()
 {
     instagrate_pro()->comments->sync_comments();
     instagrate_pro()->likes->sync_likes();
     exit;
 }
Example #19
0
 function ajax_sync_likes()
 {
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'instagrate_pro')) {
         return 0;
     }
     if (!isset($_POST['post_id'])) {
         return 0;
     }
     $response['error'] = false;
     $response['redirect'] = '';
     instagrate_pro()->likes->sync_likes($_POST['post_id']);
     $redirect = get_admin_url() . 'edit.php?post_type=instagrate_pro&message=15';
     $response['redirect'] = $redirect;
     echo json_encode($response);
     die;
 }
Example #20
0
 /**
  * Wrapper for removing invalid chars from caption
  *
  * @param $caption
  *
  * @return mixed
  */
 function remove_invalid_characters($caption)
 {
     global $wp_version;
     if (version_compare($wp_version, '4.2', '<')) {
         // Ignore for < WP 4.2
         return $caption;
     }
     global $wpdb;
     $table = instagrate_pro()->images->get_table_name();
     $charset = $wpdb->get_col_charset($table, 'caption');
     $caption = $this->clean_up_caption($caption, $charset);
     return $caption;
 }
Example #21
0
 function ajax_load_images()
 {
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'instagrate_pro')) {
         return 0;
     }
     if (!isset($_POST['post_id'])) {
         return 0;
     }
     if (!isset($_POST['img_count'])) {
         return 0;
     }
     $response['error'] = false;
     $response['message'] = '';
     $response['next_url'] = '';
     $response['load'] = false;
     $all_count = instagrate_pro()->images->images_total($_POST['post_id']);
     if ($_POST['img_count'] < $all_count[0]->Total && Instagrate_Pro_Helper::setting('igpsettings_general_admin-images', '') != '') {
         $older_images = instagrate_pro()->images->get_images($_POST['post_id'], '', 'DESC', false, '', 20, $_POST['img_count']);
         $images = array();
         foreach ($older_images as $image) {
             $images[] = array('id' => $image->image_id, 'images' => array('thumbnail' => array('url' => $image->image_thumb_url)), 'status' => $image->status, 'media_type' => $image->media_type);
         }
         $response['images'] = $images;
     } else {
         $images = instagrate_pro()->accounts->load_images($_POST['post_id']);
         $response['stats'] = instagrate_pro()->accounts->account_stats($_POST['post_id']);
         $account_settings = get_post_meta($_POST['post_id'], '_instagrate_pro_settings', true);
         $response['images'] = $images;
         $response['next_url'] = $account_settings['next_url'];
         $response['load'] = true;
     }
     $response['message'] = 'success';
     echo json_encode($response);
     die;
 }
 function save_post_meta($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (!isset($_POST['instagrate_pro_noncename']) || !wp_verify_nonce($_POST['instagrate_pro_noncename'], plugin_basename(__FILE__))) {
         return;
     }
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     $settings = $_POST['_instagrate_pro_settings'];
     // Schedule
     if ($settings['posting_frequency'] == 'schedule') {
         $old_settings = get_post_meta($post_id, '_instagrate_pro_settings', true);
         $old_sch = isset($old_settings['posting_schedule']) ? $old_settings['posting_schedule'] : '';
         $old_day = isset($old_settings['posting_day']) ? $old_settings['posting_day'] : '';
         $old_time = isset($old_settings['posting_time']) ? $old_settings['posting_time'] : '';
         $new_sch = $settings['posting_schedule'];
         $new_day = isset($settings['posting_day']) ? $settings['posting_day'] : '';
         $new_time = $settings['posting_time'];
         if ($old_sch != $new_sch || $old_day != $new_day || $old_time != $new_time || $settings['posting_frequency'] != $old_settings['posting_frequency']) {
             instagrate_pro()->scheduler->clear_all_schedules($post_id);
             $posting_day = isset($settings['posting_day']) ? $settings['posting_day'] : '';
             instagrate_pro()->scheduler->set_schedule($post_id, $new_day, $new_time, $new_sch);
         }
     } else {
         instagrate_pro()->scheduler->clear_all_schedules($post_id);
     }
     update_post_meta($post_id, '_instagrate_pro_settings', $settings);
 }