/** * Check if the debug file exists * * @return bool */ public function debug_file_exists() { $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) { return true; } return false; }
/** * Get locations in Instagram * * @param $account_id * @param $location * @param $lat * @param $lng * @param bool $ajax * * @return array */ public function get_locations($account_id, $location, $lat, $lng, $ajax = false) { $account_settings = get_post_meta($account_id, '_instagrate_pro_settings', true); $access = $account_settings['token']; $options = get_post_meta($account_id, '_instagrate_pro_settings', true); $url = 'locations/search/'; $new_locations = array(); $distance = Instagrate_Pro_Helper::setting('igpsettings_general_location-distance', ''); if ($lat == '' || $lng == '') { $new_locations[0] = '— ' . __('Enter Location', 'instagrate-pro') . ' —'; return $new_locations; } $new_locations[0] = '— ' . __('No Locations Found', 'instagrate-pro') . ' —'; $params = array('lat' => $lat, 'lng' => $lng); if ($distance != '') { $params['distance'] = $distance; } $data = $this->do_http_request($access, $url, $params); if (!$data) { if ($ajax) { $options['ig_error'] = 'The Instagram API is currently throwing errors for large locations'; } else { $options['ig_error'] = '<strong>Instagram API Error</strong> For large locations try settings the distance to default or 500 metres in the <a href="' . admin_url('edit.php?post_type=instagrate_pro&page=instagrate-pro-settings&tab=general') . '">settings</a>'; } } else { if ($data->meta->code == 200) { $locations = $data->data; if ($locations && is_array($locations)) { $new_locations[0] = '— ' . __('Select', 'instagrate-pro') . ' —'; foreach ($locations as $ig_location) { $new_locations[$ig_location->id] = $ig_location->name; } $options['instagram_location'] = $location; $options['location_lat'] = $lat; $options['location_lng'] = $lng; } $options['ig_error'] = ''; } else { $options['ig_error'] = '<strong>' . $data->meta->error_type . '</strong> ' . $data->meta->error_message; } } update_post_meta($account_id, '_instagrate_pro_settings', $options); if ($ajax) { return array('locations' => $new_locations, 'error' => $options['ig_error']); } return $new_locations; }
<?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); } }
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; }
/** * Helper function for building a select element * * @param $name * @param $items * @param string $default * @param $options * @param string $class */ public static function metabox_select($name, $items, $default = '', $options, $class = '') { $selected = Instagrate_Pro_Helper::setting($name, $default, $options); ?> <select name="_instagrate_pro_settings[<?php echo $name; ?> ]" <?php echo $class != '' ? 'class="' . $class . '"' : ''; ?> > <?php foreach ($items as $key => $value) { ?> <option value="<?php echo $key; ?> " <?php selected($selected, $key); ?> ><?php echo $value; ?> </option> <?php } ?> </select> <?php }
/** * Register and enqueue the scripts needed for the Google Maps */ public function add_map_scripts() { global $wp_query; $posts = $wp_query->posts; if ($this->page_has_maps($posts)) { $version = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? time() : INSTAGRATEPRO_VERSION; $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_register_script('igp-google-maps', 'https://maps.googleapis.com/maps/api/js?sensor=false', array('jquery'), $version); wp_enqueue_script('igp-google-maps'); wp_register_script('igp-maps', INSTAGRATEPRO_PLUGIN_URL . "assets/js/maps{$min}.js", array('jquery', 'igp-google-maps'), $version); wp_enqueue_script('igp-maps'); $custom_rel = Instagrate_Pro_Helper::setting('igpsettings_general_lightbox-rel', 'lightbox'); wp_localize_script('igp-maps', 'igp_maps', array('lightbox_rel' => $custom_rel)); wp_register_style('igp-maps-style', INSTAGRATEPRO_PLUGIN_URL . "assets/css/maps.css", array(), $version); wp_enqueue_style('igp-maps-style'); } }
/** * Main wrapper for triggering the posting for an account * * @param $account_id * @param string $frequency * @param string $schedule * * @return mixed */ function post_account($account_id, $frequency = 'schedule', $schedule = '') { $this->account_id = $account_id; $this->account = get_post($account_id); $this->settings = (object) get_post_meta($account_id, '_instagrate_pro_settings', true); if (!$this->check_account($frequency)) { return; } if ($frequency == 'schedule') { $schedule = Instagrate_Pro_Helper::setting('posting_schedule', 'igp_daily', $this->settings); } // Lock Account instagrate_pro()->accounts->lock_account($account_id, true); instagrate_pro()->debug->make_debug('Account Now Locked'); // Set up soon defaults $this->general_defaults($frequency, $schedule); // Check the account has a token and last id if (isset($this->settings->token) && $this->settings->token == '' && isset($this->settings->last_id) && $this->settings->last_id == '') { return $this->post_exit('Account has empty token and last id'); } $this->settings->posting_frequency = Instagrate_Pro_Helper::setting('posting_frequency', 'constant', $this->settings); // Check the account has the correct frequency if ($frequency != $this->settings->posting_frequency) { return $this->post_exit('Account frequency (' . $this->settings->posting_frequency . ') is not the running frequency (' . $frequency . ')'); } // Constant specific checks if (!$this->constant_post_check()) { return; } //Account specific settings $this->account_defaults(); // Retrieve newer images from Instragam instagrate_pro()->accounts->retrieve_images($this->account_id); // Get all images pending $this->images = instagrate_pro()->images->get_images($this->account_id, 'pending', $this->image_order, !$this->dup_image, 'posting'); if (!$this->dup_image) { instagrate_pro()->images->update_duplicate_images($this->account_id); } if (!$this->images) { return $this->post_exit('0 Images to post'); } // Prepare images $this->prepare_images(); // Media Filtering $this->media_type_filtering(); // Hashtag filtering on images $this->hashtag_filtering(); // Check there are images left to post if (empty($this->images)) { return $this->post_exit('0 Images to post'); } else { $count = sizeof($this->images); instagrate_pro()->debug->make_debug('Images to post: ' . $count); $i = 0; } // Reset template tag values instagrate_pro()->tags->clear_values(); $function = $this->settings->posting_multiple; // Functions for different for posting_multiple config if (method_exists($this, $function)) { $this->{$function}($i, $count); } // Write to debug file if mode on instagrate_pro()->debug->write_debug($this->account_id); return $this->images; }
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>'; } } }
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 . '&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; } }
function meta_box_links() { $html = Instagrate_Pro_Helper::get_cron_job_html(); $html .= '<ul>'; $html .= '<li><a target="_blank" href="https://intagrate.io/docs">' . __('Documentation', 'instagrate-pro') . '</a> - ' . __('get help on what settings mean and how to use them', 'instagrate-pro') . '</li>'; $html .= '<li><a target="_blank" href="https://intagrate.io/docs/template-tags/">' . __('Template Tags', 'instagrate-pro') . '</a> - ' . __('get some simple examples of using template tags for the custom content', 'instagrate-pro') . '</li>'; $html .= '<li><a target="_blank" href="https://intagrate.io/support/">' . __('Support', 'instagrate-pro') . '</a> - ' . __('get support for the plugin', 'instagrate-pro') . '</li>'; $html .= '<li><a target="_blank" href="https://intagrate.io/category/release/">' . __('Changelog', 'instagrate-pro') . '</a> - ' . __('read the plugin\'s changelog', 'instagrate-pro') . '</li>'; $html .= '</ul>'; echo $html; }
<?php global $wpsfigp_settings; // General Settings section $wpsfigp_settings[] = array('section_id' => 'general', 'section_title' => 'Global Settings', 'section_order' => 1, 'fields' => array(array('id' => 'default-title', 'title' => __('Default Title', 'instagrate-pro'), 'desc' => __('Enter a title for posts where the Instagram image has no title.', 'instagrate-pro'), 'type' => 'text', 'std' => 'Instagram Image'), array('id' => 'title-limit-type', 'title' => __('Title Length Type', 'instagrate-pro'), 'desc' => __('Set type of length limit.', 'instagrate-pro'), 'type' => 'select', 'choices' => array('characters' => 'Characters', 'words' => 'Words'), 'std' => 'characters'), array('id' => 'title-limit', 'title' => __('Title Length Limit', 'instagrate-pro'), 'desc' => __('Enter a number of characters/words to limit the title length. Leave blank for no limit.', 'instagrate-pro'), 'type' => 'text', 'std' => ''), array('id' => 'bypass-home', 'title' => __('Bypass is_home()', 'instagrate-pro'), 'desc' => __('Bypass is_home() check on posting. This should only be used if really necessary as it will make the plugin run on every page load.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'allow-duplicates', 'title' => __('Allow Duplicate Images', 'instagrate-pro'), 'desc' => __('Allow posting of same image by different accounts', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'high-res-images', 'title' => __('High Resolution Images', 'instagrate-pro'), 'desc' => __('The Instagram API exposes images at 640x640px, but images are available at 1080x1080. Turning this on will use the higer res images but images may break as this is a bleeding edge feature.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'location-distance', 'title' => __('Instagram Location Distance', 'instagrate-pro'), 'desc' => __('Set the distance in metres of the location searching of Instagram locations.', 'instagrate-pro'), 'type' => 'select', 'choices' => array('' => 'Use Default', '500' => '500', '1000' => '1000', '2000' => '2000', '3000' => '3000', '4000' => '4000', '5000' => '5000'), 'std' => ''), array('id' => 'admin-images', 'title' => __('Images in Account Admin', 'instagrate-pro'), 'desc' => __('Set amount of images to show when the account is edited. This helps performance for accounts with a large number of images.', 'instagrate-pro'), 'type' => 'select', 'choices' => array('' => 'All', '20' => '20', '40' => '40', '60' => '60', '80' => '80', '100' => '100'), 'std' => ''), array('id' => 'image-save-name', 'title' => __('Image Name as Instagram ID', 'instagrate-pro'), 'desc' => __('When saving the images to the media library the filename will be the caption. However, by checking this box it will save the images with the Instagram image ID as the filename e.g. c6077c14fe0a11e2b55e22000a9f09fb_7.jpg. This avoids any issues with non standard characters in the filename which can lead to the images not being displayed.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'image-caption', 'title' => __('Add Caption to Saved Image', 'instagrate-pro'), 'desc' => __('When saving images to the media library this will add the "Caption" based on the above text allowing tags (eg. %%caption%% or %%caption-no-tags%%). Also runs through a filter "igp_image_caption". Leave blank for no caption.', 'instagrate-pro'), 'type' => 'text', 'std' => '%%caption-no-tags%%'), array('id' => 'lightbox-rel', 'title' => __('Lightbox Custom Rel', 'instagrate-pro'), 'desc' => __('Enter a custom rel attribute for thumbnails on multi maps to tie in with your lightbox plugin of choice.', 'instagrate-pro'), 'type' => 'text', 'std' => 'lightbox'), array('id' => 'hide-meta', 'title' => __('Hide Meta Boxes', 'instagrate-pro'), 'desc' => __('Hide meta boxes on the edit account page.', 'instagrate-pro'), 'type' => 'checkboxes', 'std' => 0, 'choices' => array('template' => 'Template Tags', 'custom' => 'Custom Meta', 'featured' => 'Custom Featured Image', 'tags' => 'Default Tags', 'map' => 'Map Settings', 'links' => 'Useful Links')), array('id' => 'credit-link', 'title' => __('Link Love', 'instagrate-pro'), 'desc' => __('Check this to enable a credit link to the plugin page after images posted.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'cron-job', 'title' => '<strong>' . __('Cron Job', 'instagrate-pro') . '</strong>', 'desc' => '', 'type' => 'custom', 'std' => Instagrate_Pro_Helper::get_cron_job_html()))); // Comments Settings section $wpsfigp_settings[] = array('section_id' => 'comments', 'section_title' => 'Comments & Likes', 'section_order' => 1, 'fields' => array(array('id' => 'enable-comments', 'title' => __('Enable Comments', 'instagrate-pro'), 'desc' => __('Enables Instagram comments imported as WordPress comments. <br><em>Only works if posts are created for each image, ie. the Multiple Images setting is set to "Post Per Image"</em>', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'auto-approve', 'title' => __('Automatically Approve Comments', 'instagrate-pro'), 'desc' => __('Enables the comments to be automatically approved in WordPress when imported from Instagram.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 0), array('id' => 'avatar', 'title' => __('Instagram Avatar', 'instagrate-pro'), 'desc' => __('Enables the use of the Instagram user\'s profile image as the comment author avatar image.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 1), array('id' => 'mentions', 'title' => __('Username Mentions', 'instagrate-pro'), 'desc' => __('Makes all mentions of an Instagram username in a comment into a link to their profile page on Instagram.', 'instagrate-pro'), 'type' => 'checkbox', 'std' => 1), array('id' => 'likes', 'title' => __('Likes', 'instagrate-pro'), 'desc' => '', 'type' => 'custom', 'std' => __('You can use the template tag %%likes%%, the shortcode [igp-likes], or the custom post meta \'ig_likes\' to display the Like count from Instagram.', 'instagrate-pro')), array('id' => 'cron-sync', 'title' => '<strong>' . __('Syncing', 'instagrate-pro') . '</strong>', 'desc' => '', 'type' => 'custom', 'std' => __('You can synchronise the comments and likes from Instagram for a specific account by clicking on the buttons on the ', 'instagrate-pro') . '<a href="' . get_admin_url() . 'edit.php?post_type=instagrate_pro">Instagrate Accounts page.</a>' . ' <p>' . __('You can also set up a UNIX Cron job on your server to synchronise all comments and likes at a certain time interval, using the this url:', 'instagrate-pro') . '</p><code>' . get_admin_url() . 'admin-ajax.php?action=instagram_sync</code>'))); // Comments Settings section $wpsfigp_settings[] = array('section_id' => 'api', 'section_title' => 'API', 'section_order' => 2, 'fields' => array(array('id' => 'enable-custom-client', 'title' => __('Use Custom Instagram API Client', 'instagrate-pro'), 'desc' => __('Connect the plugin with your own Instagram API client. Register it here', 'instagrate-pro') . ' <a target="_blank" href="http://instagram.com/developer/register/">here</a>', 'type' => 'checkbox', 'std' => 0), array('id' => 'custom-client-id', 'title' => __('Client ID', 'instagrate-pro'), 'desc' => __('Enter the Client ID once you have registered your client', 'instagrate-pro'), 'type' => 'text', 'std' => ''), array('id' => 'custom-client-secret', 'title' => __('Client Secret', 'instagrate-pro'), 'desc' => __('Enter the Client Secret once you have registered your client', 'instagrate-pro'), 'type' => 'text', 'std' => ''), array('id' => 'custom-redirect-uri', 'title' => __('Redirect URI', 'instagrate-pro'), 'desc' => '', 'type' => 'custom', 'std' => __('When registering your Instagram API client use this as your Redirect URI:<br>', 'instagrate-pro') . '<code>' . get_admin_url() . '</code>'))); // Support Settings section $wpsfigp_settings[] = array('section_id' => 'support', 'section_title' => 'License & Support', 'section_order' => 3, 'fields' => array(array('id' => 'license', 'title' => __('Intagrate License', 'instagrate-pro'), 'type' => 'license', 'std' => ''), array('id' => 'debug-mode', 'title' => __('Debug Mode', 'instagrate-pro'), 'desc' => __('Check this to enable debug mode for troubleshooting the plugin. The file debug.txt will be created in the plugin folder', 'instagrate-pro') . ' - <a href="' . plugin_dir_url(INSTAGRATEPRO_PLUGIN_FILE) . 'debug.txt">debug.txt</a>', 'type' => 'checkbox', 'std' => 0), array('id' => 'send-data', 'title' => __('Download Install Data', 'instagrate-pro'), 'desc' => '', 'type' => 'custom', 'std' => __('If you have raised an issue with us please download and attach the install data (and <a href="' . plugin_dir_url(INSTAGRATEPRO_PLUGIN_FILE) . 'debug.txt">debug.txt</a> if it exists) in your support email', 'instagrate-pro') . ' - <p><a href="' . Instagrate_Pro_Helper::get_setting_url('suuport', array('nonce' => wp_create_nonce('install-data'), 'download' => 'data')) . '" class="button">' . __('Download Data', 'instagrate-pro') . '</a></p>'), array('id' => 'useful-links', 'title' => __('Useful Links', 'instagrate-pro'), 'desc' => '', 'type' => 'custom', 'std' => 'Website: <a href="https://intagrate.io">Intagrate</a><br /> Support: <a href="https://intagrate.io/support">Support</a><br /> Changelog: <a href="https://intagrate.io/category/release/">Changelog</a><br/><br/> <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://intagrate.io" data-text="I\'m using the Intagrate WordPress plugin" data-via="intagrate">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>')));
/** * 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); } } } }
/** * Filter the comment text to replace usernames with links * * @param $content * @param $comment * * @return mixed */ public function comment_text($content, $comment = '') { if (Instagrate_Pro_Helper::setting('igpsettings_comments_mentions', '1') == 0) { return $content; } $igp_comment = get_comment_meta($comment->comment_ID, '_igp_comment_id', true); if ($igp_comment) { $content = preg_replace("/@(\\w+)/", "<a href=\"http://instagram.com/\\1\" target=\"_blank\">@\\1</a>", $content); } return $content; }
function deactivate_license() { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], plugin_basename('instagrate_pro'))) { return 0; } $ajax_response['error'] = false; $ajax_response['message'] = ''; $options = get_option('igpsettings_settings'); $license = trim(Instagrate_Pro_Helper::setting('igpsettings_support_license-key', '', $options)); $api_params = array('license' => $license, 'file' => $this->sellwire_id); $url = esc_url_raw(add_query_arg($api_params, $this->sellwire_url . 'deactivate_license')); $response = wp_remote_get($url, $this->license_args()); if (is_wp_error($response)) { $ajax_response['error'] = true; $ajax_response['message'] = $response->get_error_message(); } else { $license_data = json_decode(wp_remote_retrieve_body($response)); if (isset($license_data->license) || isset($license_data->error) && $license_data->error == 'License expired') { unset($options['igpsettings_support_license-key']); unset($options['igpsettings_support_license-status']); update_option('igpsettings_settings', $options); $ajax_response['license_status'] = 'deactivated'; $ajax_response['redirect'] = admin_url('edit.php?post_type=instagrate_pro&page=instagrate-pro-settings&tab=support'); } else { if (isset($license_data->error)) { $ajax_response['error'] = true; $ajax_response['message'] = $license_data->error; } } } echo json_encode($ajax_response); die; }