function psStyles() { echo '<style type="text/css">'; echo '.products-list { width: 100%; border-spacing: 10px;} '; echo '.products-list TD { border: 1px solid #aaa; padding: 4px; vertical-align: top; width: ' . round(100 / max(1, GS_Config::init()->get('ps_row_limit'))) . '%; } '; echo '.products-price { font-weight: bold; } '; echo '.products-description { font-size: 0.9em; text-align: left; color: #777; }'; echo '.product-table .product-image img { max-width: none; }'; echo '.product-table tr, .product-table td{ border:0; }'; echo '</style>'; }
/** * Функция для сохранения опций плагина * @include templates/admin-options.php * @return void */ public function render() { $isUpdated = FALSE; $isDeleted = FALSE; $isError = FALSE; if (isset($_POST['action'])) { switch ($_POST['action']) { case 'update': foreach (array('ps_get_enable', 'ps_download_images', 'ps_url', 'ps_page', 'ps_row_limit', 'ps_limit', 'widget_depth', 'import_price', 'import_title', 'import_vendor') as $option) { GS_Config::init()->set($option, in_array($option, array('ps_download_images', 'ps_get_enable')) ? isset($_POST[$option]) ? '1' : '0' : @$_POST[$option]); } $isUpdated = TRUE; break; case 'delete': ignore_user_abort(true); set_time_limit(36000); $type = @$_POST['type']; $agree = @$_POST['agree']; if (in_array($type, array('all', 'products', 'categories')) && $agree) { if ($type == 'all' || $type == 'products') { self::deleteProducts(); } if ($type == 'all' || $type == 'categories') { self::deleteCategories(); } $isDeleted = TRUE; } else { $isError = TRUE; } break; } } $url = GS_Config::init()->get('ps_url'); $get_enable = (int) GS_Config::init()->get('ps_get_enable'); $ps_page = GS_Config::init()->get('ps_page'); $dirname = basename(dirname(__FILE__)); $categoriesNumber = $this->calcCategories(); $productsNumber = $this->calcProducts(); require_once dirname(__FILE__) . '/templates/admin-options.php'; }
?> ?action=parse_url" target="_blank"> <input type="hidden" name="code" value="<?php echo GS_Config::init()->get('ps_access_code'); ?> " /> <input type="submit" class="button-primary archive" value="Запустить импорт" /> </form> <br /> <p>Дождитесь, чтобы импорт товаров закончился, иначе Ваша выгрузка будет неполной.</p> <form method="post" action="<?php echo admin_url('admin-ajax.php'); ?> ?action=get_direct" target="_blank"> <input type="hidden" class="code" name="code" value="<?php echo GS_Config::init()->get('ps_access_code'); ?> " /> <input type="submit" class="button-primary yandex" value="Скачать выгрузку для ЯндексДиректа" /> </form> </div> <?php } else { ?> <p style="color:red"> Внимание! Невозможно импортировать файл. Что решить эту проблему вам необходимо предпринять одно из следующих действий: <ul> <li>— Либо установить на сервере расширение для php <a href="http://www.php.net/manual/ru/book.curl.php" target="_blank">cUrl</a></li> <li>— Либо Включить в php.ini <a href="http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen" target="_blank">allow_url_fopen</a></li> </ul>
" title="<?php echo $relatedItem->post_title; ?> "><img src="<?php echo GS_PLUGIN_URL; ?> img/details.png" alt="Подробнее" /></a></p> </td> <?php } ?> </tr> </table> <?php $args = array('numberposts' => GS_Config::init()->get('ps_row_limit'), 'orderby' => 'rand', 'post_type' => 'product', 'post_status' => 'publish', 'post__not_in' => array($post->ID), 'meta_query' => array(array('key' => 'bestseller', 'value' => 1))); $bestsellers = get_posts($args); if (!empty($bestsellers)) { ?> <h3>Бестселлеры</h3> <table class="products-list"> <tr> <?php foreach ($bestsellers as $relatedItem) { ?> <td style="text-align: left;"> <div class="products-image"><a href="<?php echo get_permalink($relatedItem->ID); ?> " title="<?php echo $relatedItem->post_title;
$info = simplexml_load_file($xmlFileFullPath); // update $info->shop->name = get_bloginfo(); $info->shop->company = get_bloginfo(); $info->shop->url = get_site_url(); $i = 0; foreach ($info->shop->offers->offer as $key => $value) { global $wpdb; $post = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_title = %s", $info_nocdata->shop->offers->offer[$i]->name[0])); if (!$post) { $i++; continue; } $post_id = get_post($post)->ID; $value->url = get_permalink($post_id); if (GS_Config::init()->get('ps_download_images')) { $thumbnail_id = get_post_thumbnail_id($post_id); $image_full = wp_get_attachment_image_src($thumbnail_id, 'full'); $image_thumbnail = wp_get_attachment_image_src($thumbnail_id); $value->thumbnail = $image_thumbnail[0]; $value->picture = $image_full[0]; } unset($value->original_picture); unset($value->attributes()->gs_category_id); $i++; } // save the updated document $info->asXML(GS_PLUGIN_PATH . '/direct.xml'); copy(GS_PLUGIN_PATH . '/direct.xml', GS_PLUGIN_PATH . '/downloads/direct.xml'); $plugins_url = plugins_url(); $cur_path = plugin_basename(__FILE__);
/** * @static * Проверка разрешения на доступ к файлам cron.php и get-direct.php */ static function check_access() { if (PHP_SAPI === 'cli') { return; } $accessCode = GS_Config::init()->get('ps_access_code'); $getEnable = (int) GS_Config::init()->get('ps_get_enable'); $getCode = empty($_GET['code']) ? NULL : $_GET['code']; $postCode = empty($_POST['code']) ? NULL : $_POST['code']; if (!$postCode) { if (!$getCode) { die('Не найден код'); } elseif (!$getEnable) { die('Возможность обновления базы GET-запросом выключена'); } elseif ($getCode != $accessCode) { die('Проверьте правильность кода'); } } elseif ($postCode != $accessCode) { die('Проверьте правильность кода'); } }