Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------Αρχείο functions.php του theme (ιστοσελίδα)-----------------------------------------------------
- /* Custom συνάρτηση, εξαφάνιση τιμής στους επισκέπτες */
- add_action( 'wp_head', 'personal_message_when_logged_in' );
- function personal_message_when_logged_in() {
- if ( !is_user_logged_in() ) :
- echo "
- <style>
- .ht-product-price,.elementor-menu-cart__subtotal,.product-price,.product-subtotal,.cart-subtotal,.order-total,.price,.woolentor-cart,.cart{
- display:none!important;
- }
- </style>
- ";
- endif;
- }
- /* Custom συνάρτηση, αλλαγής email notification */
- add_filter( 'wp_new_user_notification_email' , 'edit_user_notification_email', 10, 3 );
- function edit_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) {
- $message = sprintf(__( "Καλώς ήρθες %s! Τα στοιχεία σου για να συνδεθείς στο κατάστημα είναι:" ), $user->first_name ) . "\r\n";
- $message .= sprintf(__( 'Διεύθυνση: https://collezione-eshop.com' ) ). "\r\n";
- $message .= sprintf(__( 'Όνομα Χρήστη: %s' ), $user->user_login ) . "\r\n";
- $message .= sprintf(__( 'Κωδικός: %s' ), $user->kwdikos_pelath ) . "\r\n\r\n";
- $message .= sprintf(__( 'Εάν έχετε οποιοδήποτε πρόβλημα, παρακαλώ επικοινωνήστε μαζί μας σε info@collezione-eshop.com.'), get_option( 'admin_email' ) ) . "\r\n";
- //$message .= __('Adios!');
- $wp_new_user_notification_email['message'] = $message;
- return $wp_new_user_notification_email;
- }
- function custom_user_profile_fields($user){
- if(is_object($user))
- $kwdikos_pelath = esc_attr( get_the_author_meta( 'kwdikos_pelath', $user->ID ) );
- else
- $kwdikos_pelath = null;
- ?>
- <h3>Επιπλέον Πληροφορίες</h3>
- <table class="form-table">
- <tr>
- <th><label for="kwdikos_pelath">Κωδικός Πελάτη</label></th>
- <td>
- <input type="text" class="regular-text" name="kwdikos_pelath" value="<?php echo $kwdikos_pelath; ?>" id="kwdikos_pelath" /><br />
- <span class="description">κωδικός πελάτη είναι ο κωδικός, μπαίνει οπωσδήποτε</span>
- </td>
- </tr>
- </table>
- <?php
- }
- add_action( 'show_user_profile', 'custom_user_profile_fields' );
- add_action( 'edit_user_profile', 'custom_user_profile_fields' );
- add_action( "user_new_form", "custom_user_profile_fields" );
- function save_custom_user_profile_fields($user_id){
- # again do this only if you can
- if(!current_user_can('manage_options'))
- return false;
- # save my custom field
- update_user_meta($user_id, 'kwdikos_pelath', $_POST['kwdikos_pelath']);
- }
- add_action('user_register', 'save_custom_user_profile_fields');
- add_action('profile_update', 'save_custom_user_profile_fields');
- /* Αλλαγή Logout message */
- // this adds stuff to the head. You can add a stylesheet
- // if you want, or just css like I have.
- add_action("login_head", "cust_login_head");
- function cust_login_head()
- {
- // this just changes the logo
- ?>
- <style>
- body.login #login h1 a {
- background: url('<?=plugins_url('https://collezione-eshop.com/wp-content/uploads/2019/12/logo.png',__FILE__)?>') no-repeat scroll center top transparent;
- height: 64px;
- width: 307px;
- margin-left: 10px;
- }
- </style>
- <?php
- }
- // these change the default links from wordpress to whatever you want
- add_filter('login_headertitle', create_function(false, "return 'https://collezione-eshop.com';"));
- add_filter('login_headerurl', create_function(false, "return 'https://collezione-eshop.com';"));
- --------------------------------REQUEST ΚΛΕΙΔΙ API ΑΠΟ ENTERSOFT-----------------------------------------------------
- <?php
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_PORT => "8050",
- CURLOPT_URL => "http://188.164.204.222:8050/api/login",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "{\n SubscriptionPassword: \"passx\",\n model: {\n BranchID: \"1\",\n LangID: \"el-GR\",\n Password: \"P@ssw0rd\",\n UserID: \"webadmin\"\n }\n }",
- CURLOPT_HTTPHEADER => array(
- "content-type: application/json"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- //παλαιος κωδικας δουλευει αλλα βγαζει οθονη
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- $arr = json_decode($response, true);
- $token = $arr['Model']['WebApiToken'];
- }
- --------------------------------ΔΕΔΟΜΕΝΑ ΠΡΟΙΟΝΤΩΝ ΑΠΟ ENTERSOFT-----------------------------------------------------
- <?php
- include ('api_key.php');
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_PORT => "8050",
- CURLOPT_URL => "http://188.164.204.222:8050/api/rpc/PublicQuery/ESMobileQueries/KHC_WS_Products",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "",
- CURLOPT_HTTPHEADER => array(
- "authorization: Bearer ${token}"
- ),
- ));
- $apanthsh = curl_exec($curl);
- $sfalma = curl_error($curl);
- curl_close($curl);
- if ($sfalma) {
- echo "cURL Error #:" . $sfalma;
- } else {
- //echo $apanthsh;
- }
- --------------------------------ΛΙΣΤΑ ΦΩΤΟΓΡΑΦΙΩΝ ΓΙΑ ΕΙΣΑΓΩΓΗ ΣΤΟ GOOGLE SPREADSHEET-----------------------------------------------------
- <?php
- $row = exec('ls',$output,$error);
- echo "<table>";
- while(list(,$row) = each($output)){
- echo "<tr><td>", $row, "</td></tr>";
- }
- if($error){
- echo "Error : $error<BR>";
- exit;
- }
- echo "</table>"
- ?>
- --------------------------------JAVASCRIPT ΓΙΑ ΕΙΣΑΓΩΓΗ ΔΕΔΟΜΈΝΩΝ JSON ΑΠΟ ENTERSOFT ΣΕ GOOGLE SPREADSHEET-----------------------------
- function readRows() {
- var sheet = SpreadsheetApp.getActiveSheet();
- var rows = sheet.getDataRange();
- var numRows = rows.getNumRows();
- var values = rows.getValues();
- for (var i = 0; i <= numRows - 1; i++) {
- var row = values[i];
- Logger.log(row);
- }
- };
- function onOpen() {
- var sheet = SpreadsheetApp.getActiveSpreadsheet();
- var entries = [{
- name : "Read Data",
- functionName : "readRows"
- }];
- sheet.addMenu("Script Center Menu", entries);
- };
- function ImportJSON(url, query, options) {
- return ImportJSONAdvanced(url, query, options, includeXPath_, defaultTransform_);
- }
- function ImportJSONAdvanced(url, query, options, includeFunc, transformFunc) {
- var jsondata = UrlFetchApp.fetch(url);
- var object = JSON.parse(jsondata.getContentText());
- return parseJSONObject_(object, query, options, includeFunc, transformFunc);
- }
- function URLEncode(value) {
- return encodeURIComponent(value.toString());
- }
- function parseJSONObject_(object, query, options, includeFunc, transformFunc) {
- var headers = new Array();
- var data = new Array();
- if (query && !Array.isArray(query) && query.toString().indexOf(",") != -1) {
- query = query.toString().split(",");
- }
- if (options) {
- options = options.toString().split(",");
- }
- parseData_(headers, data, "", 1, object, query, options, includeFunc);
- parseHeaders_(headers, data);
- transformData_(data, options, transformFunc);
- return hasOption_(options, "noHeaders") ? (data.length > 1 ? data.slice(1) : new Array()) : data;
- }
- function parseData_(headers, data, path, rowIndex, value, query, options, includeFunc) {
- var dataInserted = false;
- if (isObject_(value)) {
- for (key in value) {
- if (parseData_(headers, data, path + "/" + key, rowIndex, value[key], query, options, includeFunc)) {
- dataInserted = true;
- }
- }
- } else if (Array.isArray(value) && isObjectArray_(value)) {
- for (var i = 0; i < value.length; i++) {
- if (parseData_(headers, data, path, rowIndex, value[i], query, options, includeFunc)) {
- dataInserted = true;
- rowIndex++;
- }
- }
- } else if (!includeFunc || includeFunc(query, path, options)) {
- // Handle arrays containing only scalar values
- if (Array.isArray(value)) {
- value = value.join();
- }
- // Insert new row if one doesn't already exist
- if (!data[rowIndex]) {
- data[rowIndex] = new Array();
- }
- // Add a new header if one doesn't exist
- if (!headers[path] && headers[path] != 0) {
- headers[path] = Object.keys(headers).length;
- }
- // Insert the data
- data[rowIndex][headers[path]] = value;
- dataInserted = true;
- }
- return dataInserted;
- }
- function parseHeaders_(headers, data) {
- data[0] = new Array();
- for (key in headers) {
- data[0][headers[key]] = key;
- }
- }
- function transformData_(data, options, transformFunc) {
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < data[i].length; j++) {
- transformFunc(data, i, j, options);
- }
- }
- }
- function isObject_(test) {
- return Object.prototype.toString.call(test) === '[object Object]';
- }
- function isObjectArray_(test) {
- for (var i = 0; i < test.length; i++) {
- if (isObject_(test[i])) {
- return true;
- }
- }
- return false;
- }
- function includeXPath_(query, path, options) {
- if (!query) {
- return true;
- } else if (Array.isArray(query)) {
- for (var i = 0; i < query.length; i++) {
- if (applyXPathRule_(query[i], path, options)) {
- return true;
- }
- }
- } else {
- return applyXPathRule_(query, path, options);
- }
- return false;
- };
- function applyXPathRule_(rule, path, options) {
- return path.indexOf(rule) == 0;
- }
- function defaultTransform_(data, row, column, options) {
- if (!data[row][column]) {
- if (row < 2 || hasOption_(options, "noInherit")) {
- data[row][column] = "";
- } else {
- data[row][column] = data[row-1][column];
- }
- }
- if (!hasOption_(options, "rawHeaders") && row == 0) {
- if (column == 0 && data[row].length > 1) {
- removeCommonPrefixes_(data, row);
- }
- data[row][column] = toTitleCase_(data[row][column].toString().replace(/[\/\_]/g, " "));
- }
- if (!hasOption_(options, "noTruncate") && data[row][column]) {
- data[row][column] = data[row][column].toString().substr(0, 256);
- }
- if (hasOption_(options, "debugLocation")) {
- data[row][column] = "[" + row + "," + column + "]" + data[row][column];
- }
- }
- function removeCommonPrefixes_(data, row) {
- var matchIndex = data[row][0].length;
- for (var i = 1; i < data[row].length; i++) {
- matchIndex = findEqualityEndpoint_(data[row][i-1], data[row][i], matchIndex);
- if (matchIndex == 0) {
- return;
- }
- }
- for (var i = 0; i < data[row].length; i++) {
- data[row][i] = data[row][i].substring(matchIndex, data[row][i].length);
- }
- }
- function findEqualityEndpoint_(string1, string2, stopAt) {
- if (!string1 || !string2) {
- return -1;
- }
- var maxEndpoint = Math.min(stopAt, string1.length, string2.length);
- for (var i = 0; i < maxEndpoint; i++) {
- if (string1.charAt(i) != string2.charAt(i)) {
- return i;
- }
- }
- return maxEndpoint;
- }
- function toTitleCase_(text) {
- if (text == null) {
- return null;
- }
- return text.replace(/\w\S*/g, function(word) { return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); });
- }
- function hasOption_(options, option) {
- return options && options.indexOf(option) >= 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement