function woogle_plugin_updater() { $license_key = woogle_get_license_key(); if (empty($license_key)) { return; } require_once 'edd/woogle-plugin-updater.php'; $edd_updater = new Woogle_Plugin_Updater(Woogle_License_Url, woogle_get_plugin_file(), array('version' => Woogle_Version, 'license' => $license_key, 'item_name' => Woogle_License_Item_Name, 'author' => 'Patterns In the Cloud')); }
function woogle_admin_scripts() { wp_enqueue_style('woogle-admin', plugin_dir_url(woogle_get_plugin_file()) . 'css/admin.css', array(), Woogle_Version); // jquery-ui-autocomplete wp_enqueue_script('jquery-ui'); wp_enqueue_script('jquery-ui-autocomplete'); wp_enqueue_script('woogle-admin', plugin_dir_url(woogle_get_plugin_file()) . 'js/admin.js', array('jquery'), Woogle_Version); // Post edit if (strpos($_SERVER['REQUEST_URI'], '/post.php') > 0 && strpos($_SERVER['REQUEST_URI'], '&action=edit') > 0) { // Register admin script wp_register_script('woogle-product', plugin_dir_url(woogle_get_plugin_file()) . 'js/product.js', array('jquery-ui-autocomplete'), Woogle_Version); // Category options $category_options = array(); $category_top_level_options = array(); $category_option_groups = array(); $category_list_file = apply_filters('woogle-category-list-file', plugin_dir_path(woogle_get_plugin_file()) . '/resources/taxonomy.en-US.txt'); $category_list = file_get_contents($category_list_file); if (!empty($category_list)) { $delim = strpos($category_list, "\r\n") !== false ? "\r\n" : "\n"; $categories = explode($delim, $category_list); $count = count($categories); $top_level_category = ''; for ($c = 1; $c < $count; $c++) { $category_options[] = $categories[$c]; if (strpos($categories[$c], '>') === false) { $category_top_level_options[] = $categories[$c]; $top_level_category = $categories[$c]; $category_option_groups[$top_level_category] = array(); } else { $category_option_groups[$top_level_category][] = $categories[$c]; } } } // Color options $color_options = array('Black', 'Blue', 'Brown', 'Gray', 'Green', 'Orange', 'Pink', 'Purple', 'Red', 'White', 'Yellow'); // Size options $size_options = array('XXS', 'XS', 'S', 'M', 'L', 'XL', '1XL', '2XL', '3XL', '4XL', '5XL', '6XL', '00', '0', '02', '04', '06', '08', '10', '12', '14', '16', '18', '20', '22', '24', '26', '28', '30', '32', '34', '23', '24', '26', '27', '28', '29', '30', '32', '34', '36', '38', '40', '42', '44'); // Localize admin script wp_localize_script('woogle-product', 'Woogle_Product', array('category_options' => $category_options, 'category_top_level_options' => $category_top_level_options, 'category_option_groups' => $category_option_groups, 'color_options' => $color_options, 'size_options' => $size_options)); wp_enqueue_script('woogle-product'); } }
</p> <p> <a href="<?php echo esc_attr(plugin_dir_url(woogle_get_plugin_file())), 'images/2-google-api-credentials.gif'; ?> " target="_blank"> <img src="<?php echo esc_attr(plugin_dir_url(woogle_get_plugin_file())), 'images/2-google-api-credentials.gif'; ?> " width="100%" /> </a> </p> </div> <div id="woogle-thickbox-client-secret" style="display:none;"> <p><?php echo __('If you can\'t find this page, please refer to the <a href="https://woogleshopping.com">documentation.</a>', 'woogle'); ?> </p> <p> <a href="<?php echo esc_attr(plugin_dir_url(woogle_get_plugin_file())), 'images/2-google-api-credentials.gif'; ?> " target="_blank"> <img src="<?php echo esc_attr(plugin_dir_url(woogle_get_plugin_file())), 'images/2-google-api-credentials.gif'; ?> " width="100%" /> </a> </p> </div>
function woogle_status_column($column, $post_id) { if ($column == 'woogle_status') { $icon_base_url = plugin_dir_url(woogle_get_plugin_file()); $api_enabled = get_post_meta($post_id, '_woogle_enabled', true); if ($api_enabled == 'yes') { $time = time(); $expiration_time = intval(get_post_meta($post_id, '_woogle_expiration_time', true)); if ($expiration_time == 0) { // Not updated echo "<img src=\"{$icon_base_url}images/not-updated.svg\" class=\"woogle-status not-updated\" alt=\"Not updated\" title=\"Not updated\" />"; } elseif ($expiration_time > time()) { // Updated echo "<img src=\"{$icon_base_url}images/updated.svg\" class=\"woogle-status updated\" alt=\"Updated\" title=\"Updated\" />"; } else { // Expired echo "<img src=\"{$icon_base_url}images/expired.svg\" class=\"woogle-status expired\" alt=\"Expired\" title=\"Expired\" />"; } } else { // Not applicable echo "<img src=\"{$icon_base_url}images/n-a.svg\" class=\"woogle-status n-a\" alt=\"Not enabled\" title=\"Not enabled\" />"; } } }
function woogle_revoke_access_button() { include plugin_dir_path(woogle_get_plugin_file()) . 'templates/settings/revoke-access-button.php'; }
/** * Create Google client * @return Google_Client */ function woogle_create_client() { $application_name = get_option('woogle_application_name'); $client_id = get_option('woogle_client_id'); $client_secret = get_option('woogle_client_secret'); require_once plugin_dir_path(woogle_get_plugin_file()) . 'vendor/google-api-php-client/src/Google/Client.php'; $client = new Google_Client(); $client->setApplicationName($application_name); $client->setClientId($client_id); $client->setClientSecret($client_secret); $client->setRedirectUri(admin_url('admin-ajax.php?action=update_google_shopping_api')); $client->setScopes('https://www.googleapis.com/auth/content'); $client->setAccessType('offline'); $client->setApprovalPrompt('force'); return $client; }