Congratulations!

[Valid RSS] This is a valid RSS feed.

Recommendations

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

Source: https://homepage-nach-preis.de/feed/

  1. <?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
  2. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  3. xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  4. xmlns:dc="http://purl.org/dc/elements/1.1/"
  5. xmlns:atom="http://www.w3.org/2005/Atom"
  6. xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  7. xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  8. >
  9.  
  10. <channel>
  11. <title>Homepage nach Preis &#8211; Webseite erstellen lassen</title>
  12. <atom:link href="https://homepage-nach-preis.de/feed/" rel="self" type="application/rss+xml" />
  13. <link>https://homepage-nach-preis.de/</link>
  14. <description>★ Responsive Webdesigner Homepage erstellen lassen, bereits ab 299 Euro professionelle Webseite. ✓ Google-Optimiert ✓ Mobil-Optimiert &#124; Webdesign &#38; Seo</description>
  15. <lastBuildDate>Fri, 06 Sep 2024 16:40:50 +0000</lastBuildDate>
  16. <language>de</language>
  17. <sy:updatePeriod>
  18. hourly </sy:updatePeriod>
  19. <sy:updateFrequency>
  20. 1 </sy:updateFrequency>
  21.  
  22. <image>
  23. <url>https://homepage-nach-preis.de/wp-content/uploads/2021/02/cropped-icon-150x150.png</url>
  24. <title>Homepage nach Preis &#8211; Webseite erstellen lassen</title>
  25. <link>https://homepage-nach-preis.de/</link>
  26. <width>32</width>
  27. <height>32</height>
  28. </image>
  29. <item>
  30. <title>Simple Blockchain Beispiel mit Miner</title>
  31. <link>https://homepage-nach-preis.de/2024/09/06/simple-blockchain-beispiel-mit-miner/</link>
  32. <comments>https://homepage-nach-preis.de/2024/09/06/simple-blockchain-beispiel-mit-miner/#respond</comments>
  33. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  34. <pubDate>Fri, 06 Sep 2024 16:17:14 +0000</pubDate>
  35. <category><![CDATA[Allgemein]]></category>
  36. <category><![CDATA[Code]]></category>
  37. <category><![CDATA[Beispiel]]></category>
  38. <category><![CDATA[Blockchain]]></category>
  39. <category><![CDATA[download]]></category>
  40. <category><![CDATA[Miner]]></category>
  41. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8348</guid>
  42.  
  43. <description><![CDATA[<p>Wie funktioniert eine Kryptowährung bzw. eine Blockchain mit einem Proof of Work Mechanismus (Mining). Ihr Gerät unterstützt eine Wiedergabe des Videos nicht. Github: https://github.com/HNP-Christopher-Rohde/hnp-example-blockchain-with-miner Blockchain Die Blockchain in diesem System ist eine auf Blöcken basierende Kette, die kryptografisch gesichert ist. Jeder Block enthält folgende Informationen: Index: Die Position des Blocks in der Kette. Zeitstempel: Der Zeitpunkt, zu dem der Block erstellt wurde (in Unix-Zeit). Daten: Die im Block gespeicherten Informationen (in binärer Form). Vorheriger Hash: Der Hash des vorhergehenden Blocks, der die Verbindung zu diesem sicherstellt. Hash: Der eigene Hash des Blocks, der durch den Hashing-Algorithmus SHA-256 berechnet wird. Nonce: Eine Zahl, die während des Minings variiert wird, um den Hash zu finden, der den Anforderungen der Schwierigkeit entspricht. Die Blockchain wird mit einem Genesis-Block initialisiert. Jeder neue Block wird durch einen Mining-Prozess erstellt, der den Hash so anpasst, dass er den Schwierigkeitsanforderungen (Difficulty) entspricht, d. h. der Hash muss mit einer bestimmten Anzahl von Nullen beginnen. Die Schwierigkeit passt sich dynamisch an, basierend auf der Zeit, die für die Erstellung der letzten Blöcke benötigt wurde. Validität der Blockchain: Jeder Block in der Kette wird überprüft, um sicherzustellen, dass der Hash korrekt ist und der Hash des vorherigen Blocks mit....</p>
  44. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/09/06/simple-blockchain-beispiel-mit-miner/">Simple Blockchain Beispiel mit Miner</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  45. ]]></description>
  46. <content:encoded><![CDATA[<p><strong>Wie funktioniert eine Kryptowährung bzw. eine Blockchain mit einem Proof of Work Mechanismus (Mining). </strong></p>
  47. <div class="video-own" style="padding-top:5px;"><video style="width:99%;" poster="https://homepage-nach-preis.de/wp-content/uploads/2024/09/blockchain.jpg" controls controlsList="nodownload" preload="none"><source src="https://homepage-nach-preis.de/wp-content/uploads/2024/09/2024-09-06-18-38-00.mp4" type="video/mp4"/>Ihr Gerät unterstützt eine Wiedergabe des Videos nicht.</video></div>
  48. <p><strong>Github:</strong> <a href="https://github.com/HNP-Christopher-Rohde/hnp-example-blockchain-with-miner" target="_blank" rel="nofollow noopener">https://github.com/HNP-Christopher-Rohde/hnp-example-blockchain-with-miner</a></p>
  49. <h4>Blockchain</h4>
  50. <p>Die Blockchain in diesem System ist eine auf Blöcken basierende Kette, die kryptografisch gesichert ist. Jeder Block enthält folgende Informationen:</p>
  51. <p>    Index: Die Position des Blocks in der Kette.<br />
  52.    Zeitstempel: Der Zeitpunkt, zu dem der Block erstellt wurde (in Unix-Zeit).<br />
  53.    Daten: Die im Block gespeicherten Informationen (in binärer Form).<br />
  54.    Vorheriger Hash: Der Hash des vorhergehenden Blocks, der die Verbindung zu diesem sicherstellt.<br />
  55.    Hash: Der eigene Hash des Blocks, der durch den Hashing-Algorithmus SHA-256 berechnet wird.<br />
  56.    Nonce: Eine Zahl, die während des Minings variiert wird, um den Hash zu finden, der den Anforderungen der Schwierigkeit entspricht.</p>
  57. <p>Die Blockchain wird mit einem Genesis-Block initialisiert. Jeder neue Block wird durch einen Mining-Prozess erstellt, der den Hash so anpasst, dass er den Schwierigkeitsanforderungen (Difficulty) entspricht, d. h. der Hash muss mit einer bestimmten Anzahl von Nullen beginnen. Die Schwierigkeit passt sich dynamisch an, basierend auf der Zeit, die für die Erstellung der letzten Blöcke benötigt wurde.</p>
  58. <p><strong>Validität der Blockchain:</strong></p>
  59. <p>    Jeder Block in der Kette wird überprüft, um sicherzustellen, dass der Hash korrekt ist und der Hash des vorherigen Blocks mit dem gespeicherten previous_hash übereinstimmt.<br />
  60.    Es wird außerdem geprüft, ob der Block die Schwierigkeit (Difficulty) erfüllt, bevor er zur Kette hinzugefügt wird.</p>
  61. <p>Die Blockchain speichert die Blöcke auf der Festplatte (z. B. in der Datei blockchain.json) und bietet APIs für den Empfang und das Senden neuer Blöcke zwischen Peers.</p>
  62. <p><strong>Blockchain:</strong></p>
  63. <pre>
  64. use serde::{Serialize, Deserialize};
  65. use std::collections::VecDeque;
  66. use std::fs;
  67. use sha2::Digest;
  68. use hex;
  69. use std::time::{SystemTime, UNIX_EPOCH};
  70. use reqwest;
  71. use warp::Filter;
  72. use log::{info, error};
  73. use std::env;
  74. use std::sync::{Arc, Mutex};
  75.  
  76. #[derive(Serialize, Deserialize, Debug, Clone)]
  77. pub struct Block {
  78.    pub index: u64,
  79.    pub timestamp: u64,
  80.    pub data: Vec&#x3C;u8&#x3E;,
  81.    pub previous_hash: String,
  82.    pub hash: String,
  83.    pub nonce: u64,
  84. }
  85.  
  86. impl Block {
  87.    pub fn new(index: u64, data: Vec&#x3C;u8&#x3E;, previous_hash: String) -&#x3E; Self {
  88.        let timestamp = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
  89.        let mut block = Block {
  90.            index,
  91.            timestamp,
  92.            data,
  93.            previous_hash,
  94.            hash: String::new(),
  95.            nonce: 0,
  96.        };
  97.        block.hash = block.calculate_hash();
  98.        info!(&#x22;Created new block: {:?}&#x22;, block);
  99.        block
  100.    }
  101.  
  102.    pub fn calculate_hash(&#x26;self) -&#x3E; String {
  103.        let mut hasher = sha2::Sha256::new();
  104.        hasher.update(format!(&#x22;{}{}{}{}{}&#x22;, self.index, self.timestamp, hex::encode(&#x26;self.data), self.previous_hash, self.nonce));
  105.        let result = hasher.finalize();
  106.        hex::encode(result)
  107.    }
  108. }
  109.  
  110. #[derive(Serialize, Deserialize, Debug, Clone)]
  111. pub struct Blockchain {
  112.    pub chain: VecDeque&#x3C;Block&#x3E;,
  113.    pub difficulty: u32,
  114.    pub adjustment_interval: u64,
  115.    pub target_block_time: u64,
  116.    pub last_difficulty_update: u64,
  117. }
  118.  
  119. impl Blockchain {
  120.    pub fn new(difficulty: u32, adjustment_interval: u64, target_block_time: u64) -&#x3E; Self {
  121.        let mut chain = VecDeque::new();
  122.        chain.push_back(create_genesis_block());
  123.        info!(&#x22;Blockchain initialized with genesis block&#x22;);
  124.        Blockchain {
  125.            chain,
  126.            difficulty,
  127.            adjustment_interval,
  128.            target_block_time,
  129.            last_difficulty_update: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
  130.        }
  131.    }
  132.  
  133.    pub fn add_block(&#x26;mut self, data: Vec&#x3C;u8&#x3E;) {
  134.        let previous_block = self.chain.back().unwrap();
  135.        let new_block = mine_block(previous_block, data, self.difficulty);
  136.        info!(&#x22;Adding new block: {:?}&#x22;, new_block);
  137.        self.chain.push_back(new_block);
  138.    
  139.        // Update difficulty if needed
  140.        if (self.chain.len() as u64) % self.adjustment_interval == 0 {
  141.            self.update_difficulty_based_on_time();
  142.        }
  143.    
  144.        if let Err(e) = self.save_to_file(&#x22;blockchain.json&#x22;) {
  145.            error!(&#x22;Failed to save blockchain after adding block: {}&#x22;, e);
  146.        }
  147.    }
  148.    
  149.    pub fn is_valid(&#x26;self) -&#x3E; bool {
  150.        for i in 1..self.chain.len() {
  151.            let current = &#x26;self.chain[i];
  152.            let previous = &#x26;self.chain[i - 1];
  153.  
  154.            if current.hash != current.calculate_hash() {
  155.                error!(&#x22;Block {} has invalid hash&#x22;, current.index);
  156.                return false;
  157.            }
  158.  
  159.            if current.previous_hash != previous.hash {
  160.                error!(&#x22;Block {} has invalid previous hash&#x22;, current.index);
  161.                return false;
  162.            }
  163.  
  164.            if !meets_difficulty(&#x26;current.hash, self.difficulty) {
  165.                error!(&#x22;Block {} does not meet difficulty&#x22;, current.index);
  166.                return false;
  167.            }
  168.        }
  169.        true
  170.    }
  171.  
  172.    pub fn save_to_file(&#x26;self, filename: &#x26;str) -&#x3E; std::io::Result&#x3C;()&#x3E; {
  173.        let serialized = serde_json::to_string(self)
  174.            .expect(&#x22;Serialization failed&#x22;);
  175.        fs::write(filename, serialized).map_err(|e| {
  176.            error!(&#x22;Failed to write blockchain to file: {}&#x22;, e);
  177.            e
  178.        })?;
  179.        info!(&#x22;Blockchain saved to file: {}&#x22;, filename);
  180.        Ok(())
  181.    }
  182.    
  183.    pub fn load_from_file(filename: &#x26;str) -&#x3E; std::io::Result&#x3C;Self&#x3E; {
  184.        match fs::read_to_string(filename) {
  185.            Ok(data) if !data.is_empty() =&#x3E; {
  186.                match serde_json::from_str::&#x3C;Blockchain&#x3E;(&#x26;data) {
  187.                    Ok(blockchain) =&#x3E; {
  188.                        info!(&#x22;Blockchain loaded from file: {}&#x22;, filename);
  189.                        Ok(blockchain)
  190.                    }
  191.                    Err(e) =&#x3E; {
  192.                        info!(&#x22;Failed to deserialize blockchain from file, creating a new one: {}&#x22;, e);
  193.                        let (difficulty, adjustment_interval, target_block_time) = load_config();
  194.                        Ok(Blockchain::new(difficulty, adjustment_interval, target_block_time))
  195.                    }
  196.                }
  197.            }
  198.            _ =&#x3E; {
  199.                info!(&#x22;Blockchain file is empty or not found. Creating a new blockchain.&#x22;);
  200.                let (difficulty, adjustment_interval, target_block_time) = load_config();
  201.                Ok(Blockchain::new(difficulty, adjustment_interval, target_block_time))
  202.            }
  203.        }
  204.    }
  205.    
  206.    pub async fn broadcast_new_block(&#x26;self, block: &#x26;Block, peers: &#x26;[&#x26;str]) -&#x3E; reqwest::Result&#x3C;()&#x3E; {
  207.        for peer in peers {
  208.            let url = format!(&#x22;{}/new-block&#x22;, peer);
  209.            info!(&#x22;Broadcasting new block to peer: {}&#x22;, url);
  210.            let result = reqwest::Client::new()
  211.                .post(&#x26;url)
  212.                .json(&#x26;block)
  213.                .send()
  214.                .await;
  215.  
  216.            match result {
  217.                Ok(_) =&#x3E; info!(&#x22;Successfully sent block to {}&#x22;, url),
  218.                Err(e) =&#x3E; error!(&#x22;Failed to send block to {}: {:?}&#x22;, url, e),
  219.            }
  220.        }
  221.        Ok(())
  222.    }
  223. </pre>
  224. <pre>
  225.    pub fn add_block_from_request(&#x26;mut self, block: Block) -&#x3E; bool {
  226.        let previous_block = self.chain.back().unwrap();
  227.  
  228.        info!(&#x22;Received block: {:?}&#x22;, block);
  229.        info!(&#x22;Last block in chain: {:?}&#x22;, previous_block);
  230.  
  231.        // Additional validation for the timestamp
  232.        if block.timestamp &#x3C;= previous_block.timestamp {
  233.            error!(&#x22;Block timestamp is not valid&#x22;);
  234.            return false;
  235.        }
  236.  
  237.        let is_valid = block.index == previous_block.index + 1
  238.            &#x26;&#x26; block.previous_hash == previous_block.hash
  239.            &#x26;&#x26; block.hash == block.calculate_hash()
  240.            &#x26;&#x26; meets_difficulty(&#x26;block.hash, self.difficulty);
  241.        
  242.        if is_valid {
  243.            info!(&#x22;Valid block received and added to chain&#x22;);
  244.            self.chain.push_back(block);
  245.            if let Err(e) = self.save_to_file(&#x22;blockchain.json&#x22;) {
  246.                error!(&#x22;Failed to save blockchain after adding block: {}&#x22;, e);
  247.            }
  248.        } else {
  249.            error!(&#x22;Invalid block received: \n\
  250.                    Index: {} \n\
  251.                    Previous Hash: {} \n\
  252.                    Expected Previous Hash: {} \n\
  253.                    Hash: {} \n\
  254.                    Calculated Hash: {} \n\
  255.                    Difficulty Met: {}&#x22;,
  256.                block.index,
  257.                block.previous_hash,
  258.                previous_block.hash,
  259.                block.hash,
  260.                block.calculate_hash(),
  261.                meets_difficulty(&#x26;block.hash, self.difficulty));
  262.        }
  263.        
  264.        is_valid
  265.    }
  266.    
  267.    pub fn update_difficulty_based_on_time(&#x26;mut self) {
  268.        let length = self.chain.len() as u64;
  269.        info!(&#x22;Chain length: {}&#x22;, length);
  270.        
  271.        if length &#x3E;= self.adjustment_interval {
  272.            let interval_start_block = &#x26;self.chain[self.chain.len() - self.adjustment_interval as usize];
  273.            let interval_end_block = self.chain.back().unwrap();
  274.    
  275.            let time_taken = interval_end_block.timestamp - interval_start_block.timestamp;
  276.            let expected_time = self.adjustment_interval * self.target_block_time;
  277.    
  278.            info!(&#x22;Time taken for the last {} blocks: {} seconds&#x22;, self.adjustment_interval, time_taken);
  279.            info!(&#x22;Expected time for the last {} blocks: {} seconds&#x22;, self.adjustment_interval, expected_time);
  280.    
  281.            if time_taken &#x3C; expected_time / 2 {
  282.                self.difficulty += 1;
  283.                info!(&#x22;Difficulty increased to {}&#x22;, self.difficulty);
  284.            } else if time_taken &#x3E; expected_time * 2 {
  285.                if self.difficulty &#x3E; 1 {
  286.                    self.difficulty -= 1;
  287.                    info!(&#x22;Difficulty decreased to {}&#x22;, self.difficulty);
  288.                }
  289.            } else {
  290.                info!(&#x22;Difficulty remains at {}&#x22;, self.difficulty);
  291.            }
  292.    
  293.            // Update the last difficulty update timestamp
  294.            self.last_difficulty_update = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
  295.        } else {
  296.            info!(&#x22;Not enough blocks to adjust difficulty.&#x22;);
  297.        }
  298.    }
  299.    
  300.    
  301.    pub fn update_difficulty(&#x26;mut self, new_difficulty: u32) {
  302.        self.difficulty = new_difficulty;
  303.        info!(&#x22;Difficulty updated to {}&#x22;, new_difficulty);
  304.        if let Err(e) = self.save_to_file(&#x22;blockchain.json&#x22;) {
  305.            error!(&#x22;Failed to save blockchain after updating difficulty: {}&#x22;, e);
  306.        }
  307.    }
  308. }
  309.  
  310. pub fn create_genesis_block() -&#x3E; Block {
  311.    Block::new(0, &#x22;Genesis Block&#x22;.as_bytes().to_vec(), &#x22;0&#x22;.to_string())
  312. }
  313.  
  314. fn meets_difficulty(hash: &#x26;str, difficulty: u32) -&#x3E; bool {
  315.    let target = vec![0u8; difficulty as usize];
  316.    let hash_bytes = hex::decode(hash).expect(&#x22;Hex decode failed&#x22;);
  317.    hash_bytes.len() &#x3E;= target.len() &#x26;&#x26; hash_bytes.starts_with(&#x26;target)
  318. }
  319.  
  320. fn mine_block(previous_block: &#x26;Block, data: Vec&#x3C;u8&#x3E;, difficulty: u32) -&#x3E; Block {
  321.    let mut new_block = Block::new(previous_block.index + 1, data.clone(), previous_block.hash.clone());
  322.  
  323.    let mut attempt = 0;
  324.  
  325.    while !meets_difficulty(&#x26;new_block.hash, difficulty) {
  326.        new_block.nonce += 1;
  327.        new_block.hash = new_block.calculate_hash();
  328.  
  329.        attempt += 1;
  330.        if attempt % 100 == 0 {
  331.            println!(&#x22;Attempt {}: Trying hash: {}&#x22;, attempt, new_block.hash);
  332.        }
  333.    }
  334.  
  335.    new_block
  336. }
  337.  
  338.  
  339. fn load_config() -&#x3E; (u32, u64, u64) {
  340.    use serde::Deserialize;
  341.    #[derive(Deserialize)]
  342.    struct Config {
  343.        initial_difficulty: u32,
  344.        adjustment_interval: u64,
  345.        target_block_time: u64,
  346.    }
  347.  
  348.    let data = fs::read_to_string(&#x22;config.json&#x22;).expect(&#x22;Unable to read config file&#x22;);
  349.    let config: Config = serde_json::from_str(&#x26;data).expect(&#x22;Unable to parse config file&#x22;);
  350.    (config.initial_difficulty, config.adjustment_interval, config.target_block_time)
  351. }
  352.  
  353. #[tokio::main]
  354. async fn main() {
  355.    env::set_var(&#x22;RUST_LOG&#x22;, &#x22;info&#x22;);
  356.    env_logger::init();
  357.  
  358.    let (initial_difficulty, adjustment_interval, target_block_time) = load_config();
  359.    let blockchain = Arc::new(Mutex::new(
  360.        Blockchain::load_from_file(&#x22;blockchain.json&#x22;).unwrap_or_else(|_| Blockchain::new(initial_difficulty, adjustment_interval, target_block_time))
  361.    ));
  362.  
  363.    let blockchain_filter = warp::any().map(move || blockchain.clone());
  364.  
  365.    let new_block = warp::post()
  366.        .and(warp::path(&#x22;new-block&#x22;))
  367.        .and(warp::body::json())
  368.        .and(blockchain_filter.clone())
  369.        .map(|block: Block, blockchain: Arc&#x3C;Mutex&#x3C;Blockchain&#x3E;&#x3E;| {
  370.            let mut blockchain = blockchain.lock().unwrap();
  371.            let response = if blockchain.add_block_from_request(block) {
  372.                &#x22;Block added successfully&#x22;
  373.            } else {
  374.                &#x22;Invalid block&#x22;
  375.            };
  376.            response
  377.        });
  378.  
  379.    let difficulty = warp::get()
  380.        .and(warp::path(&#x22;difficulty&#x22;))
  381.        .map(move || format!(&#x22;Difficulty: {}&#x22;, initial_difficulty));
  382.  
  383.    let set_difficulty = warp::post()
  384.        .and(warp::path(&#x22;set-difficulty&#x22;))
  385.        .and(warp::body::json())
  386.        .and(blockchain_filter.clone())
  387.        .map(|_new_difficulty: u32, _blockchain: Arc&#x3C;Mutex&#x3C;Blockchain&#x3E;&#x3E;| {
  388.            // Ignoring difficulty change here, as it&#x27;s handled externally
  389.            format!(&#x22;Difficulty updated to {}&#x22;, _new_difficulty)
  390.        });
  391.  
  392.    let last_block = warp::get()
  393.        .and(warp::path(&#x22;last-block&#x22;))
  394.        .and(blockchain_filter.clone())
  395.        .map(|blockchain: Arc&#x3C;Mutex&#x3C;Blockchain&#x3E;&#x3E;| {
  396.            let blockchain = blockchain.lock().unwrap();
  397.            let last_block = blockchain.chain.back().cloned().unwrap_or_else(|| create_genesis_block());
  398.            warp::reply::json(&#x26;last_block)
  399.        });
  400.  
  401.    let routes = new_block.or(difficulty).or(set_difficulty).or(last_block);
  402.  
  403.    info!(&#x22;Starting server at http://127.0.0.1:8000&#x22;);
  404.    warp::serve(routes).run(([127, 0, 0, 1], 8000)).await;
  405. }
  406.  
  407. </pre>
  408. <h4>Miner</h4>
  409. <p>Der Miner ist für die Erstellung neuer Blöcke in der Blockchain verantwortlich. Er arbeitet nach einem Proof-of-Work-Mechanismus, bei dem der Miner eine nonce-Nummer anpasst, bis ein gültiger Hash gefunden wird, der den Schwierigkeitsanforderungen entspricht.</p>
  410. <p><strong>Ablauf des Mining-Prozesses:</strong></p>
  411. <p>    Der Miner fragt den letzten Block der Blockchain von einem Server ab.<br />
  412.    Der Miner fragt die aktuelle Schwierigkeit vom Server ab.<br />
  413.    Ein neuer Block wird erstellt, indem die Daten des vorherigen Blocks verwendet werden, sowie neue Transaktionsdaten.<br />
  414.    Der Miner berechnet den Hash des neuen Blocks durch Anpassung der nonce, bis der Hash die Schwierigkeit erfüllt (d. h., der Hash beginnt mit einer bestimmten Anzahl von Nullen).<br />
  415.    Sobald ein gültiger Block gefunden wurde, wird er an den Server gesendet, der ihn zur Blockchain hinzufügt.</p>
  416. <p>Der Mining-Prozess läuft in einem Loop, sodass kontinuierlich nach neuen Blöcken gesucht wird, die der Blockchain hinzugefügt werden können.</p>
  417. <pre>
  418. use serde::{Serialize, Deserialize};
  419. use sha2::{Sha256, Digest};
  420. use std::time::{SystemTime, UNIX_EPOCH};
  421. use reqwest;
  422. use hex;
  423. use anyhow::{Result, Context};
  424. use tokio::task;
  425.  
  426. #[derive(Debug, Serialize, Deserialize, Clone)]
  427. pub struct Block {
  428.    pub index: u64,
  429.    pub timestamp: u64,
  430.    pub data: Vec&#x3C;u8&#x3E;,
  431.    pub previous_hash: String,
  432.    pub hash: String,
  433.    pub nonce: u64,
  434. }
  435.  
  436. impl Block {
  437.    pub fn new(index: u64, data: Vec&#x3C;u8&#x3E;, previous_hash: String) -&#x3E; Self {
  438.        let timestamp = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
  439.        let mut block = Block {
  440.            index,
  441.            timestamp,
  442.            data,
  443.            previous_hash,
  444.            hash: String::new(),
  445.            nonce: 0,
  446.        };
  447.        block.hash = block.calculate_hash();
  448.        block
  449.    }
  450.  
  451.    pub fn calculate_hash(&#x26;self) -&#x3E; String {
  452.        let mut hasher = Sha256::new();
  453.        hasher.update(format!(&#x22;{}{}{}{}{}&#x22;, self.index, self.timestamp, hex::encode(&#x26;self.data), self.previous_hash, self.nonce));
  454.        let result = hasher.finalize();
  455.        hex::encode(result)
  456.    }
  457. }
  458.  
  459. fn meets_difficulty(hash: &#x26;str, difficulty: u32) -&#x3E; bool {
  460.    let target = vec![0u8; difficulty as usize];
  461.    let hash_bytes = hex::decode(hash).expect(&#x22;Hex decode failed&#x22;);
  462.    hash_bytes.starts_with(&#x26;target)
  463. }
  464.  
  465. async fn mine_block(previous_block: &#x26;Block, data: Vec&#x3C;u8&#x3E;, difficulty: u32) -&#x3E; Block {
  466.    let mut new_block = Block::new(previous_block.index + 1, data.clone(), previous_block.hash.clone());
  467.  
  468.    // Parallel mining using multiple threads
  469.    let mining_task = task::spawn_blocking(move || {
  470.        let mut attempt = 0;
  471.        while !meets_difficulty(&#x26;new_block.hash, difficulty) {
  472.            new_block.nonce += 1;
  473.            new_block.hash = new_block.calculate_hash();
  474.  
  475.            attempt += 1;
  476.            if attempt % 100 == 0 {
  477.                println!(&#x22;Attempt {}: Trying hash: {}&#x22;, attempt, new_block.hash);
  478.            }
  479.        }
  480.  
  481.        new_block
  482.    });
  483.  
  484.    mining_task.await.unwrap()
  485. }
  486.  
  487. async fn get_last_block_from_server() -&#x3E; Result&#x3C;Block&#x3E; {
  488.    let client = reqwest::Client::new();
  489.    let url = &#x22;http://localhost:8000/last-block&#x22;;
  490.  
  491.    let res = client.get(url)
  492.        .send()
  493.        .await
  494.        .context(&#x22;Failed to send request to get last block&#x22;)?;
  495.  
  496.    let last_block: Block = res.json().await
  497.        .context(&#x22;Failed to parse last block&#x22;)?;
  498.    Ok(last_block)
  499. }
  500.  
  501. async fn send_block_to_server(block: &#x26;Block) -&#x3E; Result&#x3C;()&#x3E; {
  502.    let client = reqwest::Client::new();
  503.    let url = &#x22;http://localhost:8000/new-block&#x22;;
  504.  
  505.    println!(&#x22;Sending block: {:?}&#x22;, block);
  506.  
  507.    let res = client.post(url)
  508.        .json(block)
  509.        .send()
  510.        .await
  511.        .context(&#x22;Failed to send request to post new block&#x22;)?;
  512.  
  513.    let status = res.status();
  514.    let body = res.text().await
  515.        .context(&#x22;Failed to read response text&#x22;)?;
  516.  
  517.    if status.is_success() {
  518.        println!(&#x22;Block successfully sent to server.&#x22;);
  519.    } else {
  520.        println!(&#x22;Failed to send block to server: {} - {}&#x22;, status, body);
  521.    }
  522.  
  523.    Ok(())
  524. }
  525. </pre>
  526. <pre>
  527. async fn get_difficulty_from_server() -&#x3E; Result&#x3C;u32&#x3E; {
  528.    let client = reqwest::Client::new();
  529.    let url = &#x22;http://localhost:8000/difficulty&#x22;;
  530.  
  531.    let res = client.get(url)
  532.        .send()
  533.        .await
  534.        .context(&#x22;Failed to send request to get difficulty&#x22;)?;
  535.  
  536.    let difficulty_str = res.text().await
  537.        .context(&#x22;Failed to read difficulty response&#x22;)?;
  538.    let difficulty = difficulty_str.trim_start_matches(&#x22;Difficulty: &#x22;)
  539.        .parse::&#x3C;u32&#x3E;()
  540.        .context(&#x22;Failed to parse difficulty&#x22;)?;
  541.  
  542.    Ok(difficulty)
  543. }
  544.  
  545. async fn display_difficulty() -&#x3E; Result&#x3C;()&#x3E; {
  546.    let difficulty = get_difficulty_from_server().await
  547.        .context(&#x22;Error retrieving difficulty from server&#x22;)?;
  548.  
  549.    println!(&#x22;Current Difficulty: {}&#x22;, difficulty);
  550.  
  551.    Ok(())
  552. }
  553.  
  554. #[tokio::main]
  555. async fn main() -&#x3E; Result&#x3C;()&#x3E; {
  556.    loop {
  557.        // Anzeige der aktuellen Schwierigkeit
  558.        display_difficulty().await
  559.            .context(&#x22;Error displaying difficulty&#x22;)?;
  560.  
  561.        // Hol die Schwierigkeit vom Server
  562.        let difficulty = get_difficulty_from_server().await
  563.            .context(&#x22;Error retrieving difficulty from server&#x22;)?;
  564.  
  565.        // Hol den letzten Block vom Server
  566.        let previous_block = get_last_block_from_server().await
  567.            .context(&#x22;Error retrieving last block from server&#x22;)?;
  568.  
  569.        let data = b&#x22;Block data&#x22;.to_vec();
  570.        let new_block = mine_block(&#x26;previous_block, data, difficulty).await;
  571.  
  572.        send_block_to_server(&#x26;new_block).await
  573.            .context(&#x22;Error sending block to server&#x22;)?;
  574.  
  575.        // Warte eine gewisse Zeit, bevor der n&#xE4;chste Block erstellt wird
  576.        tokio::time::sleep(tokio::time::Duration::from_secs(0)).await; // Wartezeit erh&#xF6;ht
  577.    }
  578. }
  579.  
  580. </pre>
  581. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/09/06/simple-blockchain-beispiel-mit-miner/">Simple Blockchain Beispiel mit Miner</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  582. ]]></content:encoded>
  583. <wfw:commentRss>https://homepage-nach-preis.de/2024/09/06/simple-blockchain-beispiel-mit-miner/feed/</wfw:commentRss>
  584. <slash:comments>0</slash:comments>
  585. <enclosure url="https://homepage-nach-preis.de/wp-content/uploads/2024/09/2024-09-06-18-38-00.mp4" length="41740699" type="video/mp4" />
  586.  
  587. </item>
  588. <item>
  589. <title>WooCommerce für Windows &#8211; Software von HNP</title>
  590. <link>https://homepage-nach-preis.de/2024/05/28/woocommerce-fuer-windows-software-von-hnp/</link>
  591. <comments>https://homepage-nach-preis.de/2024/05/28/woocommerce-fuer-windows-software-von-hnp/#respond</comments>
  592. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  593. <pubDate>Tue, 28 May 2024 19:08:50 +0000</pubDate>
  594. <category><![CDATA[Homepage]]></category>
  595. <category><![CDATA[Onlineshop]]></category>
  596. <category><![CDATA[Webdesign]]></category>
  597. <category><![CDATA[App]]></category>
  598. <category><![CDATA[Client]]></category>
  599. <category><![CDATA[software]]></category>
  600. <category><![CDATA[Verbinundung]]></category>
  601. <category><![CDATA[Windows]]></category>
  602. <category><![CDATA[Woocommerce]]></category>
  603. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8298</guid>
  604.  
  605. <description><![CDATA[<p>Entfesseln Sie das volle Potenzial Ihres WooCommerce-Shops mit unserer leistungsstarken Windows-Software Ihr Gerät unterstützt eine Wiedergabe des Videos nicht. Wenn Sie einen WooCommerce-Shop betreiben, wissen Sie, wie wichtig effizientes und zuverlässiges Management ist. Unsere innovative Windows-Software wurde speziell entwickelt, um Ihre Verwaltung zu vereinfachen und Ihre Produktivität zu steigern. Mit einer Vielzahl von Funktionen, die speziell auf die Bedürfnisse von WooCommerce-Shop-Betreibern zugeschnitten sind, bietet unsere Software alles, was Sie benötigen, um Ihren Shop nahtlos zu verwalten. &#160; Bestellungen verwalten leicht gemacht Unsere Software bietet eine umfassende Übersicht über alle Bestellungen in Ihrem Shop. Sie können Bestellungen nach Kundenname, Order-ID oder anderen Daten filtern und sofort aktualisieren. Mit dem intelligenten Stornierungssystem können Sie Bestellungen und einzelne Produkte sicher und effizient stornieren. Dank der automatischen Aktualisierungsfunktion bleiben Ihre Daten immer auf dem neuesten Stand. Weitere Highlights umfassen: Manuelle und automatische Rückerstattungen Bestellnotizen einsehen und E-Mails an Kunden senden Druck- und Kopierfunktionen für Bestellungen &#160; Produktmanagement auf höchstem Niveau Verwalten Sie alle Ihre Produkte, von einfachen bis hin zu variablen Produkten, direkt über unsere Software. Bearbeiten Sie Preise, Namen, Lagerbestände und SEO-Daten mühelos. Unsere Software unterstützt Sie dabei, Produktbilder hochzuladen und zu ändern und bietet eine eigene Browserfunktion zum Ansehen Ihrer Produkte. Durch....</p>
  606. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/05/28/woocommerce-fuer-windows-software-von-hnp/">WooCommerce für Windows &#8211; Software von HNP</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  607. ]]></description>
  608. <content:encoded><![CDATA[<h3>Entfesseln Sie das volle Potenzial Ihres WooCommerce-Shops mit unserer leistungsstarken Windows-Software</h3>
  609. <div class="video-own" style="padding-top:5px;"><video style="width:99%;" poster="https://homepage-nach-preis.de/wp-content/uploads/2024/05/poster-hnp-win-woo.jpg" controls controlsList="nodownload" preload="none"><source src="https://homepage-nach-preis.de/wp-content/uploads/2024/06/HNP-Win-Manager-fuer-WooCommerce-WooCommerce-fuer-Windows-Software.mp4" type="video/mp4"/>Ihr Gerät unterstützt eine Wiedergabe des Videos nicht.</video></div>
  610. <p>Wenn Sie einen WooCommerce-Shop betreiben, wissen Sie, wie wichtig effizientes und zuverlässiges Management ist. Unsere innovative Windows-Software wurde speziell entwickelt, um Ihre Verwaltung zu vereinfachen und Ihre Produktivität zu steigern. Mit einer Vielzahl von Funktionen, die speziell auf die Bedürfnisse von WooCommerce-Shop-Betreibern zugeschnitten sind, bietet unsere Software alles, was Sie benötigen, um Ihren Shop nahtlos zu verwalten.</p>
  611. <p>&nbsp;</p>
  612. <h4><strong>Bestellungen verwalten leicht gemacht</strong></h4>
  613. <p>Unsere Software bietet eine umfassende Übersicht über alle Bestellungen in Ihrem Shop. Sie können Bestellungen nach Kundenname, Order-ID oder anderen Daten filtern und sofort aktualisieren. Mit dem intelligenten Stornierungssystem können Sie Bestellungen und einzelne Produkte sicher und effizient stornieren. Dank der automatischen Aktualisierungsfunktion bleiben Ihre Daten immer auf dem neuesten Stand. Weitere Highlights umfassen:</p>
  614. <ul>
  615. <li>Manuelle und automatische Rückerstattungen</li>
  616. <li>Bestellnotizen einsehen und E-Mails an Kunden senden</li>
  617. <li>Druck- und Kopierfunktionen für Bestellungen</li>
  618. </ul>
  619. <p>&nbsp;</p>
  620. <h4><strong>Produktmanagement auf höchstem Niveau</strong></h4>
  621. <p>Verwalten Sie alle Ihre Produkte, von einfachen bis hin zu variablen Produkten, direkt über unsere Software. Bearbeiten Sie Preise, Namen, Lagerbestände und SEO-Daten mühelos. Unsere Software unterstützt Sie dabei, Produktbilder hochzuladen und zu ändern und bietet eine eigene Browserfunktion zum Ansehen Ihrer Produkte. Durch die Filter- und Aktualisierungsfunktionen behalten Sie stets den Überblick und können sofort auf Änderungen reagieren.</p>
  622. <p>&nbsp;</p>
  623. <h4><strong>Kunden- und Benutzerverwaltung optimiert</strong></h4>
  624. <p>Die Verwaltung von Nutzern und Kunden war noch nie so einfach. Mit unserer Software können Sie alle Benutzerinformationen einsehen und bearbeiten, einschließlich Name, Rolle, E-Mail und Rechnungsdaten. Sicherheitsfunktionen verhindern unbefugte Änderungen an Administratoren. Versenden Sie Passwortrücksetzungs-E-Mails und individuelle Nachrichten direkt aus der Software.</p>
  625. <p>&nbsp;</p>
  626. <h4><strong>Effizientes Gutschein-Management</strong></h4>
  627. <p>Unsere Software ermöglicht es Ihnen, Gutscheine zu verwalten, zu bearbeiten und zu erstellen. Filtern Sie Gutscheine nach Code, E-Mail oder anderen Daten und aktualisieren Sie sie automatisch. Sie können Gutscheine löschen und neue mit denselben Daten erstellen, was Ihre Marketingstrategien erheblich vereinfacht.</p>
  628. <p>&nbsp;</p>
  629. <h4><strong>Bewertungen im Griff</strong></h4>
  630. <p>Behalten Sie alle Bewertungen Ihrer Produkte im Blick. Filtern Sie Bewertungen nach Produkt, E-Mail oder anderen Daten und bearbeiten Sie sie direkt in der Software. Mit der automatischen Aktualisierungsfunktion sind Ihre Daten stets aktuell, und Sie können unerwünschte Bewertungen einfach löschen.</p>
  631. <p>&nbsp;</p>
  632. <h4><strong>Umfassende Statistikfunktionen</strong></h4>
  633. <p>Verfolgen Sie Ihre Verkaufsleistung mit unserem Sales over Time-Diagramm, das die Verkäufe der letzten 12 Monate anzeigt. Drucken Sie Diagramme aus und behalten Sie den Überblick über Ihre Geschäftsentwicklung.</p>
  634. <p>&nbsp;</p>
  635. <h4><strong>Leistungsstarke Tools für mehr Effizienz</strong></h4>
  636. <p>Unsere Software bietet eine Reihe von Tools, die speziell entwickelt wurden, um Ihre Arbeit zu erleichtern:</p>
  637. <ul>
  638. <li><strong>CSV Produkt Import:</strong> Erstellen Sie Produkte durch CSV-Dateien, validieren Sie Daten vor dem Upload und unterstützen Sie unbegrenzte Produktmengen.</li>
  639. <li><strong>Massen-Preis-Veränderung:</strong> Passen Sie Preise von allen Produkten im Shop an, entweder in Euro oder Prozent.</li>
  640. <li><strong>Massen-Email-Funktionen:</strong> Versenden Sie E-Mails an alle Nutzer oder Kunden, ähnlich wie bei einer Newsletter-Funktion.</li>
  641. <li><strong>Shop Nachrichten:</strong> Platzieren und aktualisieren Sie individuelle Nachrichten auf Ihrer Webseite mit Shortcodes.</li>
  642. <li><strong>Zahlungseinstellungen:</strong> Aktivieren oder deaktivieren Sie Zahlungsmöglichkeiten mit einem Klick.</li>
  643. <li><strong>Update Plugins und WordPress:</strong> Aktualisieren Sie Plugins und die WordPress-Version direkt über die Software.</li>
  644. </ul>
  645. <p>&nbsp;</p>
  646. <h4><strong>Warum unsere Software?</strong></h4>
  647. <p>Unsere Software ist mehr als nur ein Verwaltungswerkzeug. Sie ist Ihr Partner für ein effizientes und erfolgreiches WooCommerce-Management. Mit einer benutzerfreundlichen Oberfläche und robusten Funktionen optimieren Sie Ihre Geschäftsprozesse und sparen wertvolle Zeit. Machen Sie sich das Leben leichter und steigern Sie Ihre Produktivität – mit unserer maßgeschneiderten Lösung für WooCommerce.</p>
  648. <p>Lassen Sie sich diese Chance nicht entgehen! Testen Sie unsere Software und erleben Sie, wie einfach und effizient das Management Ihres WooCommerce-Shops sein kann. Kontaktieren Sie uns noch heute und erfahren Sie mehr darüber, wie unsere Software Ihnen helfen kann, Ihre Geschäftsziele zu erreichen.<br />
  649. &nbsp;</p>
  650. <p><strong>Kostenloser Demo Download, mehr Informationen und Lizenzschlüssel für Vollversion kaufen:</strong><br />
  651. <a href="https://shop.homepage-nach-preis.de/produkt/hnp-windows-manager-fuer-woocommerce/" target="_blank" rel="noopener nofollow">https://shop.homepage-nach-preis.de/produkt/hnp-windows-manager-fuer-woocommerce/</a></p>
  652. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/05/28/woocommerce-fuer-windows-software-von-hnp/">WooCommerce für Windows &#8211; Software von HNP</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  653. ]]></content:encoded>
  654. <wfw:commentRss>https://homepage-nach-preis.de/2024/05/28/woocommerce-fuer-windows-software-von-hnp/feed/</wfw:commentRss>
  655. <slash:comments>0</slash:comments>
  656. <enclosure url="https://homepage-nach-preis.de/wp-content/uploads/2024/06/HNP-Win-Manager-fuer-WooCommerce-WooCommerce-fuer-Windows-Software.mp4" length="38556131" type="video/mp4" />
  657.  
  658. </item>
  659. <item>
  660. <title>WordPress Rest API Schnittstelle mit Firewall</title>
  661. <link>https://homepage-nach-preis.de/2024/05/22/wordpress-rest-api-schnittstelle-mit-firewall/</link>
  662. <comments>https://homepage-nach-preis.de/2024/05/22/wordpress-rest-api-schnittstelle-mit-firewall/#respond</comments>
  663. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  664. <pubDate>Wed, 22 May 2024 12:41:18 +0000</pubDate>
  665. <category><![CDATA[Allgemein]]></category>
  666. <category><![CDATA[Homepage]]></category>
  667. <category><![CDATA[Webdesign]]></category>
  668. <category><![CDATA[Wordpress Code]]></category>
  669. <category><![CDATA[API]]></category>
  670. <category><![CDATA[Firewall]]></category>
  671. <category><![CDATA[Schnitstelle]]></category>
  672. <category><![CDATA[wordpress]]></category>
  673. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8247</guid>
  674.  
  675. <description><![CDATA[<p>Registrierung der benutzerdefinierten REST-Route Die Funktion zur Registrierung der REST-API-Route wird verwendet, um einen neuen Endpunkt in WordPress hinzuzuf&#xFC;gen. Dieser Endpunkt erm&#xF6;glicht es, externe Anfragen an WordPress zu senden und eine Antwort zu erhalten. Schritte der Registrierung: Hook zur Initialisierung der REST-API: Mit add_action(&#x27;rest_api_init&#x27;, function () { &#8230; }); wird eine anonyme Funktion registriert, die w&#xE4;hrend der Initialisierung der REST-API aufgerufen wird. Definition der Route: Innerhalb dieser anonymen Funktion wird register_rest_route aufgerufen, um die Route zu definieren. Namespace: &#x27;hnp_api_firewall/v1&#x27; legt den Namespace fest, der als Versionierung der API dient. Route: &#x27;/api&#x27; ist der spezifische Endpunkt innerhalb des Namespace. Optionen: Ein Array von Optionen, darunter: Methode: &#x27;methods&#x27; =&#x3E; &#x27;POST&#x27; spezifiziert, dass die Route nur POST-Anfragen akzeptiert. Callback: &#x27;callback&#x27; =&#x3E; &#x27;hnp_api_firewall_callback&#x27; gibt die Funktion an, die aufgerufen wird, wenn die Route erreicht wird. Berechtigung: &#x27;permission_callback&#x27; =&#x3E; &#x27;hnp_api_firewall_combined_permissions&#x27; bestimmt die Funktion, die die Berechtigungen f&#xFC;r den Zugriff auf die Route &#xFC;berpr&#xFC;ft. Kombinierte Berechtigungs- und Blockierungslogik Die Funktion hnp_api_firewall_combined_permissions dient dazu, die Berechtigungen und Blockierungslogik zu kombinieren. Sie wird aufgerufen, bevor die Haupt-Callback-Funktion ausgef&#xFC;hrt wird, um sicherzustellen, dass nur berechtigte Anfragen zugelassen werden. Schritte der Berechtigungspr&#xFC;fung: IP-&#xDC;berpr&#xFC;fung: Die IP-Adresse des Anfragenden wird &#xFC;berpr&#xFC;ft, um festzustellen, ob sie blockiert ist. Wenn die IP-Adresse blockiert ist....</p>
  676. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/05/22/wordpress-rest-api-schnittstelle-mit-firewall/">WordPress Rest API Schnittstelle mit Firewall</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  677. ]]></description>
  678. <content:encoded><![CDATA[<p><strong><br />
  679. Registrierung der benutzerdefinierten REST-Route</strong></p>
  680. <p>Die Funktion zur Registrierung der REST-API-Route wird verwendet, um einen neuen Endpunkt in WordPress hinzuzuf&#xFC;gen. Dieser Endpunkt erm&#xF6;glicht es, externe Anfragen an WordPress zu senden und eine Antwort zu erhalten.</p>
  681. <p><strong>Schritte der Registrierung:</strong></p>
  682. <p>    Hook zur Initialisierung der REST-API: Mit add_action(&#x27;rest_api_init&#x27;, function () { &#8230; }); wird eine anonyme Funktion registriert, die w&#xE4;hrend der Initialisierung der REST-API aufgerufen wird.<br />
  683.    Definition der Route: Innerhalb dieser anonymen Funktion wird register_rest_route aufgerufen, um die Route zu definieren.<br />
  684.        Namespace: &#x27;hnp_api_firewall/v1&#x27; legt den Namespace fest, der als Versionierung der API dient.<br />
  685.        Route: &#x27;/api&#x27; ist der spezifische Endpunkt innerhalb des Namespace.<br />
  686.        Optionen: Ein Array von Optionen, darunter:<br />
  687.            Methode: &#x27;methods&#x27; =&#x3E; &#x27;POST&#x27; spezifiziert, dass die Route nur POST-Anfragen akzeptiert.<br />
  688.            Callback: &#x27;callback&#x27; =&#x3E; &#x27;hnp_api_firewall_callback&#x27; gibt die Funktion an, die aufgerufen wird, wenn die Route erreicht wird.<br />
  689.            Berechtigung: &#x27;permission_callback&#x27; =&#x3E; &#x27;hnp_api_firewall_combined_permissions&#x27; bestimmt die Funktion, die die Berechtigungen f&#xFC;r den Zugriff auf die Route &#xFC;berpr&#xFC;ft.</p>
  690. <p><strong>Kombinierte Berechtigungs- und Blockierungslogik</strong></p>
  691. <p>Die Funktion hnp_api_firewall_combined_permissions dient dazu, die Berechtigungen und Blockierungslogik zu kombinieren. Sie wird aufgerufen, bevor die Haupt-Callback-Funktion ausgef&#xFC;hrt wird, um sicherzustellen, dass nur berechtigte Anfragen zugelassen werden.</p>
  692. <p><strong>Schritte der Berechtigungspr&#xFC;fung:</strong></p>
  693. <p>    IP-&#xDC;berpr&#xFC;fung: Die IP-Adresse des Anfragenden wird &#xFC;berpr&#xFC;ft, um festzustellen, ob sie blockiert ist.<br />
  694.        Wenn die IP-Adresse blockiert ist und die Blockierungsdauer noch nicht abgelaufen ist, wird der Zugriff verweigert.<br />
  695.        Wenn die Blockierungsdauer abgelaufen ist, wird die IP-Adresse entsperrt und die Blockierungsinformationen werden zur&#xFC;ckgesetzt.</p>
  696. <p>    &#xDC;berpr&#xFC;fung der API-Benutzer und -Geheimnisse: Die Kopfzeilen der Anfrage werden auf g&#xFC;ltige API-Benutzer und -Geheimnisse &#xFC;berpr&#xFC;ft.<br />
  697.        Wenn die Anmeldedaten korrekt sind, wird der Z&#xE4;hler f&#xFC;r g&#xFC;ltige Versuche erh&#xF6;ht.<br />
  698.        Wenn die Anmeldedaten falsch sind, wird der Z&#xE4;hler f&#xFC;r ung&#xFC;ltige Versuche erh&#xF6;ht.<br />
  699.            Wenn die Anzahl ung&#xFC;ltiger Versuche einen bestimmten Schwellenwert &#xFC;berschreitet (z.B. 50), wird die IP-Adresse blockiert.</p>
  700. <p>    Versuchsverfolgung: Die Anzahl der erfolgreichen und fehlgeschlagenen Anmeldeversuche wird verfolgt, um die Blockierungslogik zu unterst&#xFC;tzen.</p>
  701. <p><strong>R&#xFC;ckgabewert</strong></p>
  702. <p>    Erfolgreiche Berechtigung: Wenn die Berechtigung erfolgreich ist, gibt die Funktion true zur&#xFC;ck, wodurch die Haupt-Callback-Funktion hnp_api_firewall_callback aufgerufen wird.<br />
  703.    Fehlgeschlagene Berechtigung: Wenn die Berechtigung fehlschl&#xE4;gt, wird ein Fehler zur&#xFC;ckgegeben und die Haupt-Callback-Funktion wird nicht ausgef&#xFC;hrt.</p>
  704. <p><strong>Haupt-Callback-Funktion</strong></p>
  705. <p>Die Haupt-Callback-Funktion hnp_api_firewall_callback wird aufgerufen, wenn die Berechtigung erfolgreich ist und die Route erreicht wird. Sie gibt eine JSON-Antwort mit dem Dateninhalt zur&#xFC;ck, der in diesem Fall ein einfaches Beispiel mit {&#x22;testdata&#x22;: &#x22;test&#x22;} ist.</p>
  706. <pre>
  707.  
  708. // Register the custom REST route
  709. add_action(&#x27;rest_api_init&#x27;, function () {
  710.    register_rest_route(&#x27;hnp_api_firewall/v1&#x27;, &#x27;/api&#x27;, array(
  711.        &#x27;methods&#x27; =&#x3E; &#x27;POST&#x27;,
  712.        &#x27;callback&#x27; =&#x3E; &#x27;hnp_api_firewall_callback&#x27;,
  713.        &#x27;permission_callback&#x27; =&#x3E; &#x27;hnp_api_firewall_combined_permissions&#x27;,
  714.    ));
  715. });
  716.  
  717. // Combined function to handle permissions and blocking logic
  718. function hnp_api_firewall_combined_permissions(WP_REST_Request $request) {
  719.    $ip_address = sanitize_text_field($_SERVER[&#x27;REMOTE_ADDR&#x27;]);
  720.    $blocked_ips = get_option(&#x27;hnp_blocked_ips&#x27;, array());
  721.  
  722.    // Check if IP is blocked
  723.    if (isset($blocked_ips[$ip_address])) {
  724.        $block_info = $blocked_ips[$ip_address];
  725.        $block_time = $block_info[&#x27;block_time&#x27;];
  726.        $block_duration = $block_info[&#x27;block_duration&#x27;];
  727.        $current_time = current_time(&#x27;timestamp&#x27;);
  728.  
  729.        // If current time is less than block time + block duration, deny access
  730.        if ($current_time &#x3C; ($block_time + $block_duration)) {
  731.            return new WP_Error(&#x27;blocked_ip&#x27;, &#x27;Your IP is temporarily blocked due to too many attempts.&#x27;, array(&#x27;status&#x27; =&#x3E; 403));
  732.        } else {
  733.            // Unblock IP and reset attempts after block duration
  734.            unset($blocked_ips[$ip_address]);
  735.            update_option(&#x27;hnp_blocked_ips&#x27;, $blocked_ips);
  736.        }
  737.    }
  738.  
  739.    // Check API user and secret
  740.    $api_user = $request-&#x3E;get_header(&#x27;APIUser&#x27;);
  741.    $api_secret = $request-&#x3E;get_header(&#x27;APISecret&#x27;);
  742.    $valid_api_user = &#x27;4GI53seaRLu!FK9XEiAk323U6M!f2bT7Sda28ZqsaegQCn0!Y121Y1L&#x27;;
  743.    $valid_api_secret = &#x27;091572EddV!YcTKGR3Q13a!CM6TN!UWbPqFRdwa1XpP!1g8o32aaJD4&#x27;;
  744.  
  745.    // Tracking attempts
  746.    $attempts = get_option(&#x27;hnp_attempts&#x27;, array());
  747.  
  748.    if (!isset($attempts[$ip_address])) {
  749.        $attempts[$ip_address] = array(
  750.            &#x27;valid_count&#x27; =&#x3E; 0,
  751.            &#x27;invalid_count&#x27; =&#x3E; 0,
  752.            &#x27;invalid_license_count&#x27; =&#x3E; 0,
  753.            &#x27;first_attempt_time&#x27; =&#x3E; current_time(&#x27;timestamp&#x27;)
  754.        );
  755.    }
  756.  
  757.    $permission_granted = null !== $api_user &#x26;&#x26; $api_user === $valid_api_user &#x26;&#x26; null !== $api_secret &#x26;&#x26; $api_secret === $valid_api_secret;
  758.  
  759.    if ($permission_granted) {
  760.        $attempts[$ip_address][&#x27;valid_count&#x27;]++;
  761.    } else {
  762.        $attempts[$ip_address][&#x27;invalid_count&#x27;]++;
  763.  
  764.        // Block IP if invalid attempts exceed threshold (e.g., 50)
  765.        if ($attempts[$ip_address][&#x27;invalid_count&#x27;] &#x3E;= 50) {
  766.            $blocked_ips[$ip_address] = array(&#x27;block_time&#x27; =&#x3E; current_time(&#x27;timestamp&#x27;), &#x27;block_duration&#x27; =&#x3E; 12 * HOUR_IN_SECONDS);
  767.            update_option(&#x27;hnp_blocked_ips&#x27;, $blocked_ips);
  768.            return new WP_Error(&#x27;blocked_ip&#x27;, &#x27;Your IP is temporarily blocked due to too many invalid attempts for API Secret/Username.&#x27;, array(&#x27;status&#x27; =&#x3E; 403));
  769.        }
  770.  
  771.        update_option(&#x27;hnp_attempts&#x27;, $attempts);
  772.        return new WP_Error(&#x27;invalid_credentials&#x27;, &#x27;Invalid API Secret key or password.&#x27;, array(&#x27;status&#x27; =&#x3E; 403));
  773.    }
  774.  
  775.    // Reset invalid attempts on successful authentication
  776.    if (isset($attempts[$ip_address])) {
  777.        unset($attempts[$ip_address][&#x27;invalid_count&#x27;]);
  778.        update_option(&#x27;hnp_attempts&#x27;, $attempts);
  779.    }
  780.  
  781.    return true;
  782. }
  783.  
  784. function hnp_api_firewall_callback() {
  785.    return new WP_REST_Response(array(
  786.        &#x27;testdata&#x27; =&#x3E; &#x27;test&#x27;
  787.    ), 200);
  788. }
  789.  
  790. </pre>
  791. <p><strong>cUrl Anfrage zum Testen:</strong></p>
  792. <pre>
  793. curl -X POST https://yourdomain.com/wp-json/hnp_api_firewall/v1/api \
  794.     -H &#x22;APIUser: 4GI53seaRLu!FK9XEiAk323U6M!f2bT7Sda28ZqsaegQCn0!Y121Y1L&#x22; \
  795.     -H &#x22;APISecret: 091572EddV!YcTKGR3Q13a!CM6TN!UWbPqFRdwa1XpP!1g8o32aaJD4&#x22;
  796.  
  797. </pre>
  798. <p><strong>PHP Anfrage zum Testen:</strong></p>
  799. <pre>
  800. &#x3C;?php
  801.  
  802. function call_hnp_api_firewall() {
  803.    $url = &#x27;https://yourdomain.com/wp-json/hnp_api_firewall/v1/api&#x27;;
  804.    
  805.    $args = array(
  806.        &#x27;headers&#x27; =&#x3E; array(
  807.            &#x27;APIUser&#x27; =&#x3E; &#x27;4GI53seaRLu!FK9XEiAk323U6M!f2bT7Sda28ZqsaegQCn0!Y121Y1L&#x27;,
  808.            &#x27;APISecret&#x27; =&#x3E; &#x27;091572EddV!YcTKGR3Q13a!CM6TN!UWbPqFRdwa1XpP!1g8o32aaJD4&#x27;
  809.        ),
  810.        &#x27;body&#x27; =&#x3E; array(
  811.            // Any additional data you want to send in the body
  812.        )
  813.    );
  814.  
  815.    $response = wp_remote_post($url, $args);
  816.  
  817.    if (is_wp_error($response)) {
  818.        $error_message = $response-&#x3E;get_error_message();
  819.        echo &#x22;Something went wrong: $error_message&#x22;;
  820.    } else {
  821.        $response_body = wp_remote_retrieve_body($response);
  822.        echo &#x27;Response:&#x3C;br&#x3E;&#x27;;
  823.        echo &#x27;&#x3C;pre&#x3E;&#x27;;
  824.        print_r(json_decode($response_body, true));
  825.        echo &#x27;&#x3C;/pre&#x3E;&#x27;;
  826.    }
  827. }
  828.  
  829. // Call the function
  830. call_hnp_api_firewall();
  831.  
  832. ?&#x3E;
  833.  
  834. </pre>
  835. <p><strong>C# Anfrage zum Testen:</strong></p>
  836. <pre>
  837. using System;
  838. using System.Net.Http;
  839. using System.Net.Http.Headers;
  840. using System.Threading.Tasks;
  841.  
  842. class Program
  843. {
  844.    private static async Task CallHnpApiFirewallAsync()
  845.    {
  846.        var url = &#x22;https://yourdomain.com/wp-json/hnp_api_firewall/v1/api&#x22;;
  847.        
  848.        using (var client = new HttpClient())
  849.        {
  850.            // Set the APIUser and APISecret headers
  851.            client.DefaultRequestHeaders.Add(&#x22;APIUser&#x22;, &#x22;4GI53seaRLu!FK9XEiAk323U6M!f2bT7Sda28ZqsaegQCn0!Y121Y1L&#x22;);
  852.            client.DefaultRequestHeaders.Add(&#x22;APISecret&#x22;, &#x22;091572EddV!YcTKGR3Q13a!CM6TN!UWbPqFRdwa1XpP!1g8o32aaJD4&#x22;);
  853.  
  854.            // Optionally set the content of the request (if needed)
  855.            var content = new StringContent(&#x22;&#x22;, System.Text.Encoding.UTF8, &#x22;application/json&#x22;);
  856.  
  857.            try
  858.            {
  859.                var response = await client.PostAsync(url, content);
  860.  
  861.                if (response.IsSuccessStatusCode)
  862.                {
  863.                    var responseBody = await response.Content.ReadAsStringAsync();
  864.                    Console.WriteLine(&#x22;Response:&#x22;);
  865.                    Console.WriteLine(responseBody);
  866.                }
  867.                else
  868.                {
  869.                    Console.WriteLine($&#x22;Error: {response.StatusCode}&#x22;);
  870.                }
  871.            }
  872.            catch (Exception ex)
  873.            {
  874.                Console.WriteLine($&#x22;Exception: {ex.Message}&#x22;);
  875.            }
  876.        }
  877.    }
  878.  
  879.    static void Main(string[] args)
  880.    {
  881.        Task.Run(() =&#x3E; CallHnpApiFirewallAsync()).GetAwaiter().GetResult();
  882.    }
  883. }
  884.  
  885. </pre>
  886. <p><strong>Sicherheit:</strong></p>
  887. <p>Anzahl der möglichen Kombinationen bei BrutForceAttacken</p>
  888. <p>Einzelne Schlüssel:</p>
  889. <p>Für einen einzelnen Schlüssel mit 50 Zeichen und 94 möglichen Zeichen pro Position ergibt sich:<br />
  890. 945094 hoch50<br />
  891. Zwei Schlüssel kombiniert</p>
  892. <p>Da beide Schlüssel unabhängig voneinander betrachtet werden, multiplizieren wir die Anzahl der möglichen Kombinationen beider Schlüssel:</p>
  893. <p>(94 hoch50)×(94 hoch50)(94 hoch50)×(94 hoch50)</p>
  894. <p><strong>Dies entspricht:</strong><br />
  895. 9410094 hoch100</p>
  896. <p><strong>Zeit für einen Brute-Force-Angriff</strong></p>
  897. <p>Angenommen, ein Computer kann 1 Milliarde (1.000.000.000) Kombinationen pro Sekunde testen:</p>
  898. <p>    Anzahl der Kombinationen:<br />
  899.        Die Anzahl der Kombinationen für einen Schlüssel: 945094 hoch50 (eine extrem große Zahl)<br />
  900.        Die Anzahl der Kombinationen für beide Schlüssel: 9410094 hoch100 (noch viel größer)</p>
  901. <p><strong>    Zeit für Brute-Force:</strong><br />
  902.        Selbst wenn ein Computer 1 Milliarde Kombinationen pro Sekunde testen könnte, würde das Testen aller Kombinationen von zwei Schlüsseln extrem lange dauern.<br />
  903.        Zum Vergleich:<br />
  904.            Eine Milliarde Sekunden sind etwa 31,7 Jahre.</p>
  905. <p><strong>            Die Anzahl der Kombinationen für 9410094 hoch100 ist so groß, dass selbst mit extrem schneller Hardware Billionen von Jahren benötigt würden, um alle Kombinationen zu testen.</strong></p>
  906. <p><strong>Durch die Rate Limitierung der Firewall wird die Zeit auf Milliarden von Jahren erhöht, zudem sind DDOS oder ähnliche Hacking-Angriffe nicht möglich. Die Schnittstelle wird somit zusätzlich geschützt. </strong></p>
  907. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/05/22/wordpress-rest-api-schnittstelle-mit-firewall/">WordPress Rest API Schnittstelle mit Firewall</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  908. ]]></content:encoded>
  909. <wfw:commentRss>https://homepage-nach-preis.de/2024/05/22/wordpress-rest-api-schnittstelle-mit-firewall/feed/</wfw:commentRss>
  910. <slash:comments>0</slash:comments>
  911. </item>
  912. <item>
  913. <title>HNP Win Data Handler – Datenaustausch zwischen WordPress &#038; Windows</title>
  914. <link>https://homepage-nach-preis.de/2024/04/27/hnp-win-data-handler-datenaustausch-zwischen-wordpress-windows/</link>
  915. <comments>https://homepage-nach-preis.de/2024/04/27/hnp-win-data-handler-datenaustausch-zwischen-wordpress-windows/#respond</comments>
  916. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  917. <pubDate>Sat, 27 Apr 2024 13:27:14 +0000</pubDate>
  918. <category><![CDATA[Homepage]]></category>
  919. <category><![CDATA[Webdesign]]></category>
  920. <category><![CDATA[Wordpress Code]]></category>
  921. <category><![CDATA[API]]></category>
  922. <category><![CDATA[Code]]></category>
  923. <category><![CDATA[download]]></category>
  924. <category><![CDATA[HNP Win Data Handler]]></category>
  925. <category><![CDATA[Rest]]></category>
  926. <category><![CDATA[software]]></category>
  927. <category><![CDATA[Verbindung]]></category>
  928. <category><![CDATA[Windows]]></category>
  929. <category><![CDATA[wordpress]]></category>
  930. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8223</guid>
  931.  
  932. <description><![CDATA[<p>In einer Zeit, in der die Integration verschiedener Technologien zunehmend an Bedeutung gewinnt, bietet der &#8220;HNP Win Data Handler&#8221; eine effiziente Lösung für die sichere Datenübertragung zwischen einer WordPress-Website und einer externen C#-Anwendung. Dieses System stellt eine maßgeschneiderte REST API zur Verfügung, die speziell dafür entwickelt wurde, um von jeder C#-basierten Anwendung aus auf die Daten einer WordPress-Seite zuzugreifen. Was der HNP Win Data Handler macht Der HNP Win Data Handler ist ein WordPress-Plugin kombiniert mit einer C#-Anwendung, die zusammenarbeiten, um Daten sicher zu verwalten und auszutauschen. Das WordPress-Plugin definiert spezifische REST-API-Endpunkte, die es einer C#-Anwendung ermöglichen, Daten zu lesen (GET) und zu schreiben (POST). Diese Daten können für eine Vielzahl von Anwendungen nützlich sein, beispielsweise für das Abrufen und Aktualisieren von Konfigurationseinstellungen, Nutzerdaten oder anderen dynamischen Inhalten, die auf der WordPress-Seite gepflegt werden. Download Exe &#038; WordPress Plugin (sofort kostenlos nutzbar): [sdm_download id=&#8221;8231&#8243; fancy=&#8221;0&#8243;] Shortcode in WordPress für Anzeige der Daten: &#x5B;hnp_win_data_display] Github: https://github.com/HNP-Christopher-Rohde/Hnp-win-data-handler/tree/main C# Source-Code für die Win EXE / Anwendung: Die C#-Komponente handhabt die Benutzereingaben und interagiert direkt mit der REST-API. Sie bietet Funktionen zum Ändern der Domain-URL, zum Laden von Daten aus WordPress und zum Speichern von Änderungen an den Daten. Diese Flexibilität macht es möglich,....</p>
  933. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/27/hnp-win-data-handler-datenaustausch-zwischen-wordpress-windows/">HNP Win Data Handler – Datenaustausch zwischen WordPress &#038; Windows</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  934. ]]></description>
  935. <content:encoded><![CDATA[<p>In einer Zeit, in der die Integration verschiedener Technologien zunehmend an Bedeutung gewinnt, bietet der &#8220;HNP Win Data Handler&#8221; eine effiziente Lösung für die sichere Datenübertragung zwischen einer WordPress-Website und einer externen C#-Anwendung. Dieses System stellt eine maßgeschneiderte REST API zur Verfügung, die speziell dafür entwickelt wurde, um von jeder C#-basierten Anwendung aus auf die Daten einer WordPress-Seite zuzugreifen.</p>
  936. <p><strong>Was der HNP Win Data Handler macht</strong></p>
  937. <p>Der HNP Win Data Handler ist ein WordPress-Plugin kombiniert mit einer C#-Anwendung, die zusammenarbeiten, um Daten sicher zu verwalten und auszutauschen. Das WordPress-Plugin definiert spezifische REST-API-Endpunkte, die es einer C#-Anwendung ermöglichen, Daten zu lesen (GET) und zu schreiben (POST). Diese Daten können für eine Vielzahl von Anwendungen nützlich sein, beispielsweise für das Abrufen und Aktualisieren von Konfigurationseinstellungen, Nutzerdaten oder anderen dynamischen Inhalten, die auf der WordPress-Seite gepflegt werden.</p>
  938. <p><strong>Download Exe &#038; WordPress Plugin (sofort kostenlos nutzbar):</strong><br />
  939. [sdm_download id=&#8221;8231&#8243; fancy=&#8221;0&#8243;]<br />
  940. Shortcode in WordPress für Anzeige der Daten: &#x5B;hnp_win_data_display]</p>
  941. <p><strong>Github:</strong><br />
  942. <a href="https://github.com/HNP-Christopher-Rohde/Hnp-win-data-handler/tree/main" rel="nofollow noopener" target="_blank">https://github.com/HNP-Christopher-Rohde/Hnp-win-data-handler/tree/main</a></p>
  943. <p><strong>C# Source-Code für die Win EXE / Anwendung:</strong><br />
  944. Die C#-Komponente handhabt die Benutzereingaben und interagiert direkt mit der REST-API. Sie bietet Funktionen zum Ändern der Domain-URL, zum Laden von Daten aus WordPress und zum Speichern von Änderungen an den Daten. Diese Flexibilität macht es möglich, die Datenverwaltung von jeder C#-basierten Benutzeroberfläche aus zu steuern.</p>
  945. <pre>
  946. // HNP Win Data Handler v.1.0 EXE
  947. // Author: HNP C.R.
  948. // Author URI: https://homepage-nach-preis.de/
  949. // Licence: Creative Commons Non-Commercial
  950.  
  951. using System;
  952. using System.IO;
  953. using System.Net.Http;
  954. using System.Threading.Tasks;
  955. using Newtonsoft.Json;
  956.  
  957. class hnp_win_data_Main
  958. {
  959.    private static readonly HttpClient client = new HttpClient();
  960.    private static string domainFilePath = &#x22;hnp_win_data_domain.txt&#x22;;
  961.    private static string? domainUrl = null;
  962.  
  963.    private const string SecretKey = &#x22;9418BB768671A389&#x22;;
  964.  
  965.    static async Task Main(string[] args)
  966.    {
  967.        client.DefaultRequestHeaders.Add(&#x22;X-Secret-Key&#x22;, SecretKey);
  968.  
  969.        await LoadDomain();
  970.        while (true)
  971.        {
  972.            Console.WriteLine(&#x22;\nMenu:&#x22;);
  973.            Console.WriteLine(&#x22;1. Change Domain&#x22;);
  974.            Console.WriteLine(&#x22;2. Load Data from WordPress&#x22;);
  975.            Console.WriteLine(&#x22;3. Change and Save Data&#x22;);
  976.            Console.Write(&#x22;Select an option: &#x22;);
  977.  
  978.            string? option = Console.ReadLine();
  979.            switch (option)
  980.            {
  981.                case &#x22;1&#x22;:
  982.                    ChangeDomain();
  983.                    break;
  984.                case &#x22;2&#x22;:
  985.                    await LoadDataFromWordPress();
  986.                    break;
  987.                case &#x22;3&#x22;:
  988.                    await ChangeAndSaveData();
  989.                    break;
  990.                default:
  991.                    Console.WriteLine(&#x22;Invalid option.&#x22;);
  992.                    break;
  993.            }
  994.        }
  995.    }
  996.  
  997.    static async Task LoadDomain()
  998.    {
  999.        if (File.Exists(domainFilePath))
  1000.        {
  1001.            domainUrl = await File.ReadAllTextAsync(domainFilePath) ?? string.Empty;
  1002.            Console.WriteLine($&#x22;Loaded domain: {domainUrl}&#x22;);
  1003.        }
  1004.        else
  1005.        {
  1006.            Console.Write(&#x22;Enter domain URL: &#x22;);
  1007.            domainUrl = Console.ReadLine();
  1008.            if (!string.IsNullOrWhiteSpace(domainUrl))
  1009.            {
  1010.                await File.WriteAllTextAsync(domainFilePath, domainUrl);
  1011.            }
  1012.        }
  1013.    }
  1014.  
  1015.    static void ChangeDomain()
  1016.    {
  1017.        Console.Write(&#x22;Enter new domain URL: &#x22;);
  1018.        string? newDomainUrl = Console.ReadLine();
  1019.        if (!string.IsNullOrWhiteSpace(newDomainUrl))
  1020.        {
  1021.            domainUrl = newDomainUrl;
  1022.            File.WriteAllText(domainFilePath, domainUrl);
  1023.            Console.WriteLine(&#x22;Domain updated successfully.&#x22;);
  1024.        }
  1025.        else
  1026.        {
  1027.            Console.WriteLine(&#x22;Invalid domain URL provided.&#x22;);
  1028.        }
  1029.    }
  1030.  
  1031.    static async Task LoadDataFromWordPress()
  1032.    {
  1033.        if (!string.IsNullOrWhiteSpace(domainUrl))
  1034.        {
  1035.            try
  1036.            {
  1037.                HttpResponseMessage response = await client.GetAsync(domainUrl + &#x22;/wp-json/hnp-win-data/v1/data&#x22;);
  1038.                response.EnsureSuccessStatusCode();
  1039.                string responseBody = await response.Content.ReadAsStringAsync();
  1040.                string decodedData = JsonConvert.DeserializeObject&#x3C;string&#x3E;(responseBody) ?? &#x22;Default or empty data&#x22;;
  1041.                Console.WriteLine(&#x22;Data loaded: &#x22; + decodedData);
  1042.            }
  1043.            catch (HttpRequestException e)
  1044.            {
  1045.                Console.WriteLine(&#x22;\nException Caught!&#x22;);
  1046.                Console.WriteLine(&#x22;Message :{0} &#x22;, e.Message);
  1047.            }
  1048.        }
  1049.        else
  1050.        {
  1051.            Console.WriteLine(&#x22;Domain URL is not set. Please set the domain URL first.&#x22;);
  1052.        }
  1053.    }
  1054.  
  1055.    static async Task ChangeAndSaveData()
  1056.    {
  1057.        Console.Write(&#x22;Enter new data value: &#x22;);
  1058.        string? newData = Console.ReadLine();
  1059.        if (!string.IsNullOrWhiteSpace(newData) &#x26;&#x26; !string.IsNullOrWhiteSpace(domainUrl))
  1060.        {
  1061.            var content = new StringContent($&#x22;\&#x22;{newData}\&#x22;&#x22;, System.Text.Encoding.UTF8, &#x22;application/json&#x22;);
  1062.            try
  1063.            {
  1064.                HttpResponseMessage response = await client.PostAsync(domainUrl + &#x22;/wp-json/hnp-win-data/v1/data&#x22;, content);
  1065.                response.EnsureSuccessStatusCode();
  1066.                Console.WriteLine(&#x22;Data saved successfully.&#x22;);
  1067.            }
  1068.            catch (HttpRequestException e)
  1069.            {
  1070.                Console.WriteLine(&#x22;\nException Caught!&#x22;);
  1071.                Console.WriteLine(&#x22;Message :{0} &#x22;, e.Message);
  1072.            }
  1073.        }
  1074.        else
  1075.        {
  1076.            Console.WriteLine(&#x22;Invalid data value or domain URL is not set.&#x22;);
  1077.        }
  1078.    }
  1079. }
  1080.  
  1081. </pre>
  1082. <p><strong>PHP Source Code für das WordPress Plugin:</strong><br />
  1083. Das Plugin registriert zwei REST-API-Endpunkte: einen für GET-Anfragen, um Daten abzurufen, und einen für POST-Anfragen, um Daten zu aktualisieren. Jede Anfrage wird über eine Funktion verarbeitet, die den geheimen Schlüssel überprüft, um sicherzustellen, dass nur berechtigte Anfragen bearbeitet werden.</p>
  1084. <pre>
  1085. &#x3C;?php
  1086.  
  1087. /*
  1088.  Plugin Name: HNP Win Data Handler
  1089.  Description: Handles data via custom REST API for an external C# application with security enhancements.
  1090.  Version: 1.0
  1091.  Author: HNP C.R.
  1092.  Author URI: https://homepage-nach-preis.de/
  1093.  License: GPLv3
  1094.  License URI: https://www.gnu.org/licenses/gpl-3.0.html
  1095.  Shortcode: hnp_win_data_display
  1096. */
  1097.  
  1098. define(&#x27;HNP_WIN_DATA_SECRET_KEY&#x27;, &#x27;9418BB768671A389&#x27;);  // Set your secret key here
  1099.  
  1100. // Register REST API routes
  1101. add_action(&#x27;rest_api_init&#x27;, function () {
  1102.    register_rest_route(&#x27;hnp-win-data/v1&#x27;, &#x27;/data&#x27;, array(
  1103.        &#x27;methods&#x27; =&#x3E; &#x27;GET&#x27;,
  1104.        &#x27;callback&#x27; =&#x3E; &#x27;hnp_win_data_get_data&#x27;,
  1105.        &#x27;permission_callback&#x27; =&#x3E; &#x27;hnp_win_data_check_secret_key&#x27;
  1106.    ));
  1107.    register_rest_route(&#x27;hnp-win-data/v1&#x27;, &#x27;/data&#x27;, array(
  1108.        &#x27;methods&#x27; =&#x3E; &#x27;POST&#x27;,
  1109.        &#x27;callback&#x27; =&#x3E; &#x27;hnp_win_data_set_data&#x27;,
  1110.        &#x27;permission_callback&#x27; =&#x3E; &#x27;hnp_win_data_check_secret_key&#x27;
  1111.    ));
  1112. });
  1113.  
  1114. // Function to handle GET request
  1115. function hnp_win_data_get_data(WP_REST_Request $request) {
  1116.    $value = get_option(&#x27;hnp_win_data_value&#x27;, &#x27;No data set.&#x27;);
  1117.    return new WP_REST_Response($value, 200);
  1118. }
  1119.  
  1120. // Function to handle POST request
  1121. function hnp_win_data_set_data(WP_REST_Request $request) {
  1122.    $data = $request-&#x3E;get_body();
  1123.    $clean_data = sanitize_text_field($data);
  1124.    update_option(&#x27;hnp_win_data_value&#x27;, $clean_data);
  1125.    return new WP_REST_Response(&#x27;Data updated successfully.&#x27;, 200);
  1126. }
  1127.  
  1128. // Permission check to validate secret key
  1129. function hnp_win_data_check_secret_key($request) {
  1130.    $headers = $request-&#x3E;get_headers();
  1131.    $provided_secret = $headers[&#x27;x_secret_key&#x27;][0] ?? &#x27;&#x27;;
  1132.    return $provided_secret === HNP_WIN_DATA_SECRET_KEY;
  1133. }
  1134.  
  1135. // Shortcode to display the data in the frontend
  1136. add_shortcode(&#x27;hnp_win_data_display&#x27;, &#x27;hnp_win_data_display_shortcode&#x27;);
  1137. function hnp_win_data_display_shortcode() {
  1138.    $value = get_option(&#x27;hnp_win_data_value&#x27;, &#x27;No data set.&#x27;);
  1139.    return esc_html($value);
  1140. }
  1141.  
  1142. </pre>
  1143. <p>Der HNP Win Data Handler ist ein Beispiel für die erfolgreiche Integration von Web- und Desktop-Technologien zur Datensynchronisation. Die Kombination aus einem WordPress-Plugin und einer C#-Anwendung bietet eine sichere und flexible Lösung für das Datenmanagement, die in vielen Geschäftsbereichen und Anwendungen nützlich sein kann. Mit seinem modularen Aufbau und der hohen Sicherheit stellt dieses System eine wertvolle Ressource für Entwickler dar, die in gemischten Technologieumgebungen arbeiten.</p>
  1144. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/27/hnp-win-data-handler-datenaustausch-zwischen-wordpress-windows/">HNP Win Data Handler – Datenaustausch zwischen WordPress &#038; Windows</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1145. ]]></content:encoded>
  1146. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/27/hnp-win-data-handler-datenaustausch-zwischen-wordpress-windows/feed/</wfw:commentRss>
  1147. <slash:comments>0</slash:comments>
  1148. </item>
  1149. <item>
  1150. <title>HNP WIN SHORTCODE Tool: Eine Revolution für WordPress</title>
  1151. <link>https://homepage-nach-preis.de/2024/04/26/hnp-win-shortcode-tool-eine-revolution-fuer-wordpress/</link>
  1152. <comments>https://homepage-nach-preis.de/2024/04/26/hnp-win-shortcode-tool-eine-revolution-fuer-wordpress/#respond</comments>
  1153. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  1154. <pubDate>Fri, 26 Apr 2024 19:13:58 +0000</pubDate>
  1155. <category><![CDATA[Allgemein]]></category>
  1156. <category><![CDATA[Homepage]]></category>
  1157. <category><![CDATA[Onlineshop]]></category>
  1158. <category><![CDATA[Webdesign]]></category>
  1159. <category><![CDATA[API]]></category>
  1160. <category><![CDATA[Daten]]></category>
  1161. <category><![CDATA[Hook]]></category>
  1162. <category><![CDATA[Shortcode]]></category>
  1163. <category><![CDATA[software]]></category>
  1164. <category><![CDATA[Verbindung]]></category>
  1165. <category><![CDATA[Win]]></category>
  1166. <category><![CDATA[Windows]]></category>
  1167. <category><![CDATA[wordpress]]></category>
  1168. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8216</guid>
  1169.  
  1170. <description><![CDATA[<p>Unbegrenzte Anpassung mit dem HNP WIN SHORTCODE Tool: Eine Revolution für WordPress In der Welt des Webdesigns und der Content-Verwaltungssysteme ist Flexibilität der Schlüssel. WordPress, das beliebte CMS, bietet bereits eine Vielzahl von Funktionen, aber was, wenn Sie noch weiter gehen möchten? Was ist, wenn Sie Ihre Inhalte noch individueller gestalten möchten? Hier kommt das HNP WIN SHORTCODE Tool ins Spiel &#8211; ein innovatives WordPress-Plugin in Kombination mit einer leistungsstarken Windows x64-Software, die Ihnen die unbegrenzte Erstellung und Anpassung von Shortcodes ermöglicht. Was ist das HNP WIN SHORTCODE Tool? Das HNP WIN SHORTCODE Tool besteht aus zwei Hauptkomponenten: einem WordPress-Plugin und einer Windows x64-Software. Zusammen ermöglichen sie die einfache Erstellung und Verwaltung von Shortcodes mit anpassbaren Inhalten direkt von Ihrem Desktop aus. Wie funktioniert es? Das WordPress-Plugin integriert sich nahtlos in Ihre WordPress-Installation. Nach der Installation und Aktivierung stehen Ihnen sofort alle Funktionen zur Verfügung. Sie können die Anzahl der Shortcodes festlegen und die Daten bearbeiten, alles direkt über das Backend von WordPress. Die Windows-Software bietet eine benutzerfreundliche Oberfläche, mit der Sie die Shortcodes und deren Inhalte laden und ändern können. Dank der Integration mit der WordPress-Rest-API können Sie die Änderungen direkt auf Ihrer Website veröffentlichen. Funktionen des WordPress-Plugins: Einfache....</p>
  1171. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/26/hnp-win-shortcode-tool-eine-revolution-fuer-wordpress/">HNP WIN SHORTCODE Tool: Eine Revolution für WordPress</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1172. ]]></description>
  1173. <content:encoded><![CDATA[<p><strong>Unbegrenzte Anpassung mit dem HNP WIN SHORTCODE Tool: Eine Revolution für WordPress</strong></p>
  1174. <p>In der Welt des Webdesigns und der Content-Verwaltungssysteme ist Flexibilität der Schlüssel. WordPress, das beliebte CMS, bietet bereits eine Vielzahl von Funktionen, aber was, wenn Sie noch weiter gehen möchten? Was ist, wenn Sie Ihre Inhalte noch individueller gestalten möchten? Hier kommt das HNP WIN SHORTCODE Tool ins Spiel &#8211; ein innovatives WordPress-Plugin in Kombination mit einer leistungsstarken Windows x64-Software, die Ihnen die unbegrenzte Erstellung und Anpassung von Shortcodes ermöglicht.</p>
  1175. <h3>Was ist das HNP WIN SHORTCODE Tool?</h3>
  1176. <p>Das HNP WIN SHORTCODE Tool besteht aus zwei Hauptkomponenten: einem WordPress-Plugin und einer Windows x64-Software. Zusammen ermöglichen sie die einfache Erstellung und Verwaltung von Shortcodes mit anpassbaren Inhalten direkt von Ihrem Desktop aus.</p>
  1177. <h3>Wie funktioniert es?</h3>
  1178. <p>Das WordPress-Plugin integriert sich nahtlos in Ihre WordPress-Installation. Nach der Installation und Aktivierung stehen Ihnen sofort alle Funktionen zur Verfügung. Sie können die Anzahl der Shortcodes festlegen und die Daten bearbeiten, alles direkt über das Backend von WordPress.</p>
  1179. <p>Die Windows-Software bietet eine benutzerfreundliche Oberfläche, mit der Sie die Shortcodes und deren Inhalte laden und ändern können. Dank der Integration mit der WordPress-Rest-API können Sie die Änderungen direkt auf Ihrer Website veröffentlichen.</p>
  1180. <h3>Funktionen des WordPress-Plugins:</h3>
  1181. <ul>
  1182. <li><strong>Einfache Einrichtung:</strong> Installieren und aktivieren Sie das Plugin &#8211; der Rest ist optional, da das Plugin bereits vorkonfiguriert ist.</li>
  1183. <li><strong>Backend-Verwaltung:</strong> Eine eigene Backend-Seite im Admin-Dashboard von WordPress ermöglicht die Verwaltung der Shortcodes und ihrer Inhalte.</li>
  1184. <li><strong>Anpassung:</strong> Passen Sie die Anzahl der Shortcodes an und definieren Sie die Daten, die ausgelesen und geändert werden sollen.</li>
  1185. <li><strong>Sprachunabhängig:</strong> Das Plugin ist derzeit nur in Englisch verfügbar, aber da Sie die Inhalte der Shortcodes selbst bestimmen können, ist die Sprache irrelevant.</li>
  1186. <li><strong>Performance und Sicherheit:</strong> Das Plugin nutzt pures JavaScript und ist mit PHP 7.X und PHP 8.X kompatibel. Die REST-API ist durch einen Secret Key geschützt.</li>
  1187. </ul>
  1188. <h3>Funktionen der Windows-Software:</h3>
  1189. <ul>
  1190. <li><strong>Einfache Nutzung:</strong> Starten Sie die Anwendung auf einem Windows-64-Bit-System und geben Sie Ihre Domain-Adresse ein &#8211; mehr ist nicht nötig.</li>
  1191. <li><strong>Vielseitigkeit:</strong> Die Anwendung funktioniert auf Servern, Laptops und herkömmlichen Computern.</li>
  1192. <li><strong>Anpassungsmöglichkeiten:</strong> Ändern Sie den Secret Key, die Anzahl der Shortcodes und die Domain-Adresse nach Bedarf.</li>
  1193. <li><strong>Speicherungsfunktion:</strong> Die Anwendung merkt sich die letzten Einstellungen für einen bequemen Autostart.</li>
  1194. <li><strong>Performance und Sicherheit:</strong> Nutzt keine externen Bibliotheken außer denen von Python, Netcore und GTK. Die Datenübertragung zur WordPress-Website erfolgt über die REST-API mit einem Secret Key.</li>
  1195. </ul>
  1196. <p>&nbsp;</p>
  1197. <p><strong>Mehr Informationen und Download:</strong><br />
  1198. <a href="https://shop.homepage-nach-preis.de/produkt/hnp-unlimiterte-shortcodes-schnitstelle-wordpress-windows-x64/" target="_blank" rel="nofollow noopener">https://shop.homepage-nach-preis.de/produkt/hnp-unlimiterte-shortcodes-schnitstelle-wordpress-windows-x64/</a></p>
  1199. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/26/hnp-win-shortcode-tool-eine-revolution-fuer-wordpress/">HNP WIN SHORTCODE Tool: Eine Revolution für WordPress</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1200. ]]></content:encoded>
  1201. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/26/hnp-win-shortcode-tool-eine-revolution-fuer-wordpress/feed/</wfw:commentRss>
  1202. <slash:comments>0</slash:comments>
  1203. </item>
  1204. <item>
  1205. <title>HNP System Monitor Tool: Die Brücke zwischen Windows und WordPress</title>
  1206. <link>https://homepage-nach-preis.de/2024/04/20/hnp-system-monitor-tool-die-bruecke-zwischen-windows-und-wordpress/</link>
  1207. <comments>https://homepage-nach-preis.de/2024/04/20/hnp-system-monitor-tool-die-bruecke-zwischen-windows-und-wordpress/#respond</comments>
  1208. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  1209. <pubDate>Sat, 20 Apr 2024 12:05:49 +0000</pubDate>
  1210. <category><![CDATA[Homepage]]></category>
  1211. <category><![CDATA[Onlineshop]]></category>
  1212. <category><![CDATA[Webdesign]]></category>
  1213. <category><![CDATA[Anwendung]]></category>
  1214. <category><![CDATA[Exe]]></category>
  1215. <category><![CDATA[HNP System Monitor]]></category>
  1216. <category><![CDATA[JS]]></category>
  1217. <category><![CDATA[Php]]></category>
  1218. <category><![CDATA[plugin]]></category>
  1219. <category><![CDATA[Pyhton]]></category>
  1220. <category><![CDATA[Windows]]></category>
  1221. <category><![CDATA[wordpress]]></category>
  1222. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8212</guid>
  1223.  
  1224. <description><![CDATA[<p>In der digitalen Welt von heute ist es unerlässlich, den Überblick über die Systemleistung eines Servers oder Computers zu behalten. Das HNP System Monitor Tool bietet hier eine innovative Lösung, indem es eine nahtlose Verbindung zwischen einem Windows-Computer oder Server und einer WordPress-Webseite herstellt. Aber wie funktioniert das genau? Und welche Vorteile bringt diese Verbindung mit sich? Lassen Sie uns einen tieferen Blick darauf werfen. Wie funktioniert das HNP System Monitor Tool? Das HNP System Monitor Tool nutzt eine gesicherte REST API, um die aktuelle Systemauslastung des Windows-Geräts zu erfassen und diese Daten an Ihre WordPress-Webseite zu übertragen. Dort können Sie die Daten in einer visuell strukturierten Form betrachten und analysieren. Das Beste daran? Die Einrichtung ist denkbar einfach. WordPress-Plugin: Starten und Loslegen Das mitgelieferte WordPress-Plugin ist vorkonfiguriert, sodass Sie es lediglich installieren und aktivieren müssen. Es erzeugt eine Backend-Seite in Ihrem WordPress-Admin-Dashboard, auf der Sie die Server- oder Computerleistung in Echtzeit verfolgen können. Die Daten werden ohne Neuladen der Seite aktualisiert, dank AJAX-Requests. Zudem bietet das Plugin visuelle Feedbacks durch farbige Pfeile und eine grafische Anzeige der letzten 100 Datenpunkte. Mit den integrierten Shortcodes können Sie die Daten auch im Frontend Ihrer Webseite anzeigen lassen. Exe Win Anwendung: Einfach....</p>
  1225. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/20/hnp-system-monitor-tool-die-bruecke-zwischen-windows-und-wordpress/">HNP System Monitor Tool: Die Brücke zwischen Windows und WordPress</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1226. ]]></description>
  1227. <content:encoded><![CDATA[<p>In der digitalen Welt von heute ist es unerlässlich, den Überblick über die Systemleistung eines Servers oder Computers zu behalten. Das HNP System Monitor Tool bietet hier eine innovative Lösung, indem es eine nahtlose Verbindung zwischen einem Windows-Computer oder Server und einer WordPress-Webseite herstellt. Aber wie funktioniert das genau? Und welche Vorteile bringt diese Verbindung mit sich? Lassen Sie uns einen tieferen Blick darauf werfen.<br />
  1228. Wie funktioniert das HNP System Monitor Tool?</p>
  1229. <p>Das HNP System Monitor Tool nutzt eine gesicherte REST API, um die aktuelle Systemauslastung des Windows-Geräts zu erfassen und diese Daten an Ihre WordPress-Webseite zu übertragen. Dort können Sie die Daten in einer visuell strukturierten Form betrachten und analysieren. Das Beste daran? Die Einrichtung ist denkbar einfach.<br />
  1230. WordPress-Plugin: Starten und Loslegen</p>
  1231. <p>Das mitgelieferte WordPress-Plugin ist vorkonfiguriert, sodass Sie es lediglich installieren und aktivieren müssen. Es erzeugt eine Backend-Seite in Ihrem WordPress-Admin-Dashboard, auf der Sie die Server- oder Computerleistung in Echtzeit verfolgen können. Die Daten werden ohne Neuladen der Seite aktualisiert, dank AJAX-Requests. Zudem bietet das Plugin visuelle Feedbacks durch farbige Pfeile und eine grafische Anzeige der letzten 100 Datenpunkte. Mit den integrierten Shortcodes können Sie die Daten auch im Frontend Ihrer Webseite anzeigen lassen.<br />
  1232. Exe Win Anwendung: Einfach und Effizient</p>
  1233. <p>Die begleitende Windows-64-Bit-Anwendung ist ebenfalls vorkonfiguriert. Nach dem Start der Anwendung und der Eingabe Ihrer Domain-Adresse übernimmt das System automatisch die Datenerfassung und -übertragung. Sie können den Secretkey, die Intervallzeit und andere Einstellungen direkt in der Anwendung ändern. Praktisch ist auch die Speicherungsfunktion, die die letzten Einstellungen für einen Autostart speichert.<br />
  1234. Sicherheit und Performance</p>
  1235. <p>Sowohl das WordPress-Plugin als auch die Windows-Anwendung setzen auf hohe Sicherheitsstandards. Mit Nonce-Abfragen, gesicherten AJAX-Verbindungen und Schutz vor XSS-Angriffen sind Ihre Daten stets sicher. Zudem sind beide Systeme performance-optimiert, ohne externe Bibliotheken oder Treiber zu benötigen.<br />
  1236. Flexibilität und Erweiterbarkeit</p>
  1237. <p>Das HNP System Monitor Tool bietet Ihnen die Freiheit, die Intervallzeit zum Datenaustausch nach Ihren Bedürfnissen anzupassen. Ob alle 2 Sekunden oder einmal täglich – Sie haben die Wahl. Darüber hinaus sind die Sourcefiles sowohl für das WordPress-Plugin als auch für die Windows-Anwendung im Lieferumfang enthalten. Dies ermöglicht erfahreneren Nutzern, das Tool nach Belieben anzupassen und zu erweitern.<br />
  1238. Fazit</p>
  1239. <p>Das HNP System Monitor Tool ist ein modernes und benutzerfreundliches System zur Erfassung und Visualisierung von Systemdaten. Mit seiner einfachen Einrichtung, hohen Sicherheitsstandards und Flexibilität ist es eine ideale Lösung für jeden, der die Leistung seines Windows-Computers oder Servers im Auge behalten und diese Daten nahtlos in seine WordPress-Webseite integrieren möchte.</p>
  1240. <p>Beim Kauf erhalten Sie ein fertiges Run &amp; Go WordPress-Plugin, eine Windows-64-Bit-Anwendung, sowie alle erforderlichen Sourcefiles für Anpassungen und Erweiterungen. Nutzen Sie die Gelegenheit und bringen Sie Ihre Systemüberwachung auf das nächste Level!</p>
  1241. <p><strong> Mehr Informationen:</strong></p>
  1242. <p><a href="https://shop.homepage-nach-preis.de/produkt/hnp-system-monitor-for-wordpress-windows-x64/" target="_blank" rel="nofollow noopener">https://shop.homepage-nach-preis.de/produkt/hnp-system-monitor-for-wordpress-windows-x64/</a></p>
  1243. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/20/hnp-system-monitor-tool-die-bruecke-zwischen-windows-und-wordpress/">HNP System Monitor Tool: Die Brücke zwischen Windows und WordPress</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1244. ]]></content:encoded>
  1245. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/20/hnp-system-monitor-tool-die-bruecke-zwischen-windows-und-wordpress/feed/</wfw:commentRss>
  1246. <slash:comments>0</slash:comments>
  1247. </item>
  1248. <item>
  1249. <title>WooCommerce Warenkorb Leeren &#038; Session Button</title>
  1250. <link>https://homepage-nach-preis.de/2024/04/15/woocommerce-warenkorb-leeren-session-button/</link>
  1251. <comments>https://homepage-nach-preis.de/2024/04/15/woocommerce-warenkorb-leeren-session-button/#respond</comments>
  1252. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  1253. <pubDate>Mon, 15 Apr 2024 14:27:03 +0000</pubDate>
  1254. <category><![CDATA[Allgemein]]></category>
  1255. <category><![CDATA[Onlineshop]]></category>
  1256. <category><![CDATA[Wordpress Code]]></category>
  1257. <category><![CDATA[Button]]></category>
  1258. <category><![CDATA[leeren]]></category>
  1259. <category><![CDATA[Warenkorb]]></category>
  1260. <category><![CDATA[Woocommerce]]></category>
  1261. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8204</guid>
  1262.  
  1263. <description><![CDATA[<p>Das HNP Warenkorb Leeren Button Plugin für WooCommerce und WordPress erzeugt einen Button auf der Warenkorb-Seite, welcher bei Betätigung den kompletten Warenkorb leert und zudem die Session und Cookies resetet. Download: [sdm_download id=&#8221;8202&#8243; fancy=&#8221;0&#8243;] &#x3C;?php /** Plugin Name: HNP Clear WooCommerce Cart &#x26; Session Description: Ein Plugin zum Leeren des WooCommerce Warenkorbs und L&#xF6;schen von Sessions und Cookies. Version: 1.2 Author: HNP C.R. Author URI: https://homepage-nach-preis.de/ License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html */ // Exit, wenn der Direktzugriff verhindert ist if (!defined(&#x27;ABSPATH&#x27;)) { exit; } function hnp_cwc_enqueue_scripts() { if (is_cart() &#x26;&#x26; get_option(&#x27;hnp_cwc_enable&#x27;, &#x27;no&#x27;) == &#x27;yes&#x27; &#x26;&#x26; get_option(&#x27;hnp_cwc_hook_enable&#x27;, &#x27;no&#x27;) == &#x27;yes&#x27;) { $nonce = wp_create_nonce(&#x27;hnp_cwc_nonce&#x27;); $script = &#x22; var ajaxurl = &#x27;&#x22; . admin_url(&#x27;admin-ajax.php&#x27;) . &#x22;&#x27;; var nonce = &#x27;&#x22; . $nonce . &#x22;&#x27;; document.addEventListener(&#x27;DOMContentLoaded&#x27;, function() { var clearCartButton = document.getElementById(&#x27;clear-cart&#x27;); clearCartButton.addEventListener(&#x27;click&#x27;, function() { // Clear cart var xhr = new XMLHttpRequest(); xhr.open(&#x27;POST&#x27;, ajaxurl, true); xhr.setRequestHeader(&#x27;Content-Type&#x27;, &#x27;application/x-www-form-urlencoded&#x27;); xhr.setRequestHeader(&#x27;X-WP-Nonce&#x27;, nonce); xhr.onload = function() { if (this.status &#x3E;= 200 &#x26;&#x26; this.status &#x3C; 400) { console.log(&#x27;Cart Cleared&#x27;, this.responseText); // Clear sessions and cookies var xhr2 = new XMLHttpRequest(); xhr2.open(&#x27;POST&#x27;, ajaxurl, true); xhr2.setRequestHeader(&#x27;Content-Type&#x27;, &#x27;application/x-www-form-urlencoded&#x27;); xhr2.setRequestHeader(&#x27;X-WP-Nonce&#x27;, nonce); xhr2.onload = function() { if (this.status &#x3E;= 200 &#x26;&#x26; this.status &#x3C; 400) { console.log(&#x27;Sessions and Cookies Cleared&#x27;, this.responseText); // Reload....</p>
  1264. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/15/woocommerce-warenkorb-leeren-session-button/">WooCommerce Warenkorb Leeren &#038; Session Button</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1265. ]]></description>
  1266. <content:encoded><![CDATA[<p>Das HNP Warenkorb Leeren Button Plugin für WooCommerce und WordPress erzeugt einen Button auf der Warenkorb-Seite, welcher bei Betätigung den kompletten Warenkorb leert und zudem die Session und Cookies resetet.</p>
  1267. <p><strong>Download: </strong><br />
  1268. [sdm_download id=&#8221;8202&#8243; fancy=&#8221;0&#8243;]</p>
  1269. <pre>
  1270. &#x3C;?php
  1271. /**
  1272. Plugin Name: HNP Clear WooCommerce Cart &#x26; Session
  1273. Description: Ein Plugin zum Leeren des WooCommerce Warenkorbs und L&#xF6;schen von Sessions und Cookies.
  1274. Version: 1.2
  1275. Author: HNP C.R.
  1276. Author URI: https://homepage-nach-preis.de/
  1277. License: GPLv3
  1278. License URI: https://www.gnu.org/licenses/gpl-3.0.html
  1279. */
  1280.  
  1281. // Exit, wenn der Direktzugriff verhindert ist
  1282. if (!defined(&#x27;ABSPATH&#x27;)) {
  1283.    exit;
  1284. }
  1285.  
  1286. function hnp_cwc_enqueue_scripts() {
  1287.    if (is_cart() &#x26;&#x26; get_option(&#x27;hnp_cwc_enable&#x27;, &#x27;no&#x27;) == &#x27;yes&#x27; &#x26;&#x26; get_option(&#x27;hnp_cwc_hook_enable&#x27;, &#x27;no&#x27;) == &#x27;yes&#x27;) {
  1288.        $nonce = wp_create_nonce(&#x27;hnp_cwc_nonce&#x27;);
  1289.        
  1290.        $script = &#x22;
  1291.            var ajaxurl = &#x27;&#x22; . admin_url(&#x27;admin-ajax.php&#x27;) . &#x22;&#x27;;
  1292.            var nonce = &#x27;&#x22; . $nonce . &#x22;&#x27;;
  1293.            
  1294.            document.addEventListener(&#x27;DOMContentLoaded&#x27;, function() {
  1295.                var clearCartButton = document.getElementById(&#x27;clear-cart&#x27;);
  1296.                
  1297.                clearCartButton.addEventListener(&#x27;click&#x27;, function() {
  1298.                    // Clear cart
  1299.                    var xhr = new XMLHttpRequest();
  1300.                    xhr.open(&#x27;POST&#x27;, ajaxurl, true);
  1301.                    xhr.setRequestHeader(&#x27;Content-Type&#x27;, &#x27;application/x-www-form-urlencoded&#x27;);
  1302.                    xhr.setRequestHeader(&#x27;X-WP-Nonce&#x27;, nonce);
  1303.                    xhr.onload = function() {
  1304.                        if (this.status &#x3E;= 200 &#x26;&#x26; this.status &#x3C; 400) {
  1305.                            console.log(&#x27;Cart Cleared&#x27;, this.responseText);
  1306.                            
  1307.                            // Clear sessions and cookies
  1308.                            var xhr2 = new XMLHttpRequest();
  1309.                            xhr2.open(&#x27;POST&#x27;, ajaxurl, true);
  1310.                            xhr2.setRequestHeader(&#x27;Content-Type&#x27;, &#x27;application/x-www-form-urlencoded&#x27;);
  1311.                            xhr2.setRequestHeader(&#x27;X-WP-Nonce&#x27;, nonce);
  1312.                            xhr2.onload = function() {
  1313.                                if (this.status &#x3E;= 200 &#x26;&#x26; this.status &#x3C; 400) {
  1314.                                    console.log(&#x27;Sessions and Cookies Cleared&#x27;, this.responseText);
  1315.                                    
  1316.                                    // Reload the page after clearing cart and sessions/cookies
  1317.                                    location.reload();
  1318.                                } else {
  1319.                                    console.error(&#x27;Error clearing sessions and cookies&#x27;, this);
  1320.                                }
  1321.                            };
  1322.                            xhr2.onerror = function() {
  1323.                                console.error(&#x27;Error clearing sessions and cookies&#x27;, this);
  1324.                            };
  1325.                            xhr2.send(&#x27;action=hnp_clear_sessions_cookies&#x26;nonce=&#x27; + nonce);
  1326.                            
  1327.                        } else {
  1328.                            console.error(&#x27;Error clearing cart&#x27;, this);
  1329.                        }
  1330.                    };
  1331.                    xhr.onerror = function() {
  1332.                        console.error(&#x27;Error clearing cart&#x27;, this);
  1333.                    };
  1334.                    xhr.send(&#x27;action=hnp_clear_cart_session&#x26;nonce=&#x27; + nonce);
  1335.                });
  1336.            });
  1337.        &#x22;;
  1338.        wp_add_inline_script(&#x27;jquery&#x27;, $script);
  1339.    }
  1340. }
  1341.  
  1342.  
  1343. add_action(&#x27;wp_enqueue_scripts&#x27;, &#x27;hnp_cwc_enqueue_scripts&#x27;);
  1344.  
  1345.  
  1346.  
  1347. // Register shortcode
  1348. function hnp_cwc_button_shortcode() {
  1349.    ob_start(); ?&#x3E;
  1350.    &#x3C;button id=&#x22;clear-cart&#x22;&#x3E;Warenkorb leeren&#x3C;/button&#x3E;
  1351.    &#x3C;?php
  1352.    return ob_get_clean();
  1353. }
  1354. add_shortcode(&#x27;hnp_cwc_button&#x27;, &#x27;hnp_cwc_button_shortcode&#x27;);
  1355.  
  1356. // Hook to display the button on cart page
  1357. function hnp_cwc_display_button() {
  1358.    if (get_option(&#x27;hnp_cwc_hook_enable&#x27;, &#x27;no&#x27;) == &#x27;yes&#x27;) {
  1359.        echo do_shortcode(&#x27;[hnp_cwc_button]&#x27;);
  1360.    }
  1361. }
  1362. add_action(&#x27;woocommerce_cart_actions&#x27;, &#x27;hnp_cwc_display_button&#x27;);
  1363.  
  1364. // AJAX handler to clear cart
  1365. function hnp_cwc_clear_cart() {
  1366.    check_ajax_referer(&#x27;hnp_cwc_nonce&#x27;, &#x27;nonce&#x27;);
  1367.  
  1368.    try {
  1369.        WC()-&#x3E;cart-&#x3E;empty_cart();
  1370.        echo &#x27;Cart Cleared&#x27;;
  1371.    } catch (Exception $e) {
  1372.        echo &#x27;Error clearing cart: &#x27; . $e-&#x3E;getMessage();
  1373.    }
  1374.    die();
  1375. }
  1376.  
  1377. add_action(&#x27;wp_ajax_hnp_clear_cart_session&#x27;, &#x27;hnp_cwc_clear_cart&#x27;);
  1378. add_action(&#x27;wp_ajax_nopriv_hnp_clear_cart_session&#x27;, &#x27;hnp_cwc_clear_cart&#x27;);
  1379.  
  1380. </pre>
  1381. <pre>
  1382.  
  1383. // AJAX handler to clear sessions and cookies
  1384. function hnp_cwc_clear_sessions_cookies() {
  1385.    check_ajax_referer(&#x27;hnp_cwc_nonce&#x27;, &#x27;nonce&#x27;);
  1386.  
  1387.    try {
  1388.        // Reset WooCommerce session
  1389.        WC()-&#x3E;session-&#x3E;set_customer_session_cookie(false);
  1390.        WC()-&#x3E;session-&#x3E;set_session_cookie(false);
  1391.        WC()-&#x3E;session-&#x3E;reset_session();
  1392.  
  1393.        // Unset all cookies
  1394.        foreach ($_COOKIE as $cookie_key =&#x3E; $cookie_value) {
  1395.            unset($_COOKIE[$cookie_key]);
  1396.            setcookie($cookie_key, &#x27;&#x27;, time() - 3600, &#x27;/&#x27;, $_SERVER[&#x27;HTTP_HOST&#x27;]);
  1397.            setcookie($cookie_key, &#x27;&#x27;, time() - 3600, &#x27;/&#x27;, &#x27;.&#x27; . $_SERVER[&#x27;HTTP_HOST&#x27;]);
  1398.        }
  1399.  
  1400.        echo &#x27;Sessions and Cookies Cleared&#x27;;
  1401.    } catch (Exception $e) {
  1402.        echo &#x27;Error clearing sessions and cookies: &#x27; . $e-&#x3E;getMessage();
  1403.    }
  1404.    die();
  1405. }
  1406.  
  1407.  
  1408. add_action(&#x27;wp_ajax_hnp_clear_sessions_cookies&#x27;, &#x27;hnp_cwc_clear_sessions_cookies&#x27;);
  1409. add_action(&#x27;wp_ajax_nopriv_hnp_clear_sessions_cookies&#x27;, &#x27;hnp_cwc_clear_sessions_cookies&#x27;);
  1410.  
  1411.  
  1412. // Admin settings
  1413. function hnp_cwc_admin_menu() {
  1414.    add_menu_page(
  1415.        &#x27;HNP Clear WooCommerce Cart Settings&#x27;,
  1416.        &#x27;HNP Clear WooCommerce Cart&#x27;,          
  1417.        &#x27;manage_options&#x27;,                  
  1418.        &#x27;hnp_cwc_settings&#x27;,                
  1419.        &#x27;hnp_cwc_settings_page&#x27;,            
  1420. &#x9;&#x9; plugin_dir_url(__FILE__) . &#x27;img/hnp-favi.png&#x27;                              
  1421.    );
  1422. }
  1423. add_action(&#x27;admin_menu&#x27;, &#x27;hnp_cwc_admin_menu&#x27;);
  1424.  
  1425. function hnp_cwc_settings_page() {
  1426. &#x9;if (!current_user_can(&#x27;manage_options&#x27;)) {
  1427.        return;
  1428.    }
  1429.    if ($_SERVER[&#x27;REQUEST_METHOD&#x27;] === &#x27;POST&#x27; &#x26;&#x26; check_admin_referer(&#x27;hnp_cwc_nonce&#x27;, &#x27;hnp_cwc_nonce_field&#x27;)) {
  1430.        if (isset($_POST[&#x27;hnp_cwc_enable&#x27;])) {
  1431.            update_option(&#x27;hnp_cwc_enable&#x27;, $_POST[&#x27;hnp_cwc_enable&#x27;]);
  1432.        } else {
  1433.            update_option(&#x27;hnp_cwc_enable&#x27;, &#x27;no&#x27;);
  1434.        }
  1435.  
  1436.        if (isset($_POST[&#x27;hnp_cwc_hook_enable&#x27;])) {
  1437.            update_option(&#x27;hnp_cwc_hook_enable&#x27;, $_POST[&#x27;hnp_cwc_hook_enable&#x27;]);
  1438.        } else {
  1439.            update_option(&#x27;hnp_cwc_hook_enable&#x27;, &#x27;no&#x27;);
  1440.        }
  1441.    }
  1442.  
  1443.    $enabled = get_option(&#x27;hnp_cwc_enable&#x27;, &#x27;no&#x27;);
  1444.    $hook_enabled = get_option(&#x27;hnp_cwc_hook_enable&#x27;, &#x27;no&#x27;);
  1445.    $nonce = wp_create_nonce(&#x27;hnp_cwc_nonce&#x27;);
  1446.    ?&#x3E;
  1447.    &#x3C;div class=&#x22;wrap&#x22;&#x3E;
  1448.        &#x3C;h2&#x3E;HNP Clear WooCommerce Cart Settings&#x3C;/h2&#x3E;
  1449.        &#x3C;form method=&#x22;post&#x22; action=&#x22;&#x22;&#x3E;
  1450.            &#x3C;?php wp_nonce_field(&#x27;hnp_cwc_nonce&#x27;, &#x27;hnp_cwc_nonce_field&#x27;); ?&#x3E;
  1451.            &#x3C;table class=&#x22;form-table&#x22;&#x3E;
  1452.                &#x3C;tr&#x3E;
  1453.                    &#x3C;th scope=&#x22;row&#x22;&#x3E;Allgemeine Funktion aktivieren&#x3C;/th&#x3E;
  1454.                    &#x3C;td&#x3E;
  1455.                        &#x3C;input type=&#x22;checkbox&#x22; name=&#x22;hnp_cwc_enable&#x22; value=&#x22;yes&#x22; &#x3C;?php checked(&#x27;yes&#x27;, $enabled); ?&#x3E; /&#x3E;
  1456.                    &#x3C;/td&#x3E;
  1457.                &#x3C;/tr&#x3E;
  1458.                &#x3C;tr&#x3E;
  1459.                    &#x3C;th scope=&#x22;row&#x22;&#x3E;Hook f&#xFC;r Warenkorb aktivieren&#x3C;/th&#x3E;
  1460.                    &#x3C;td&#x3E;
  1461.                        &#x3C;input type=&#x22;checkbox&#x22; name=&#x22;hnp_cwc_hook_enable&#x22; value=&#x22;yes&#x22; &#x3C;?php checked(&#x27;yes&#x27;, $hook_enabled); ?&#x3E; /&#x3E;
  1462.                    &#x3C;/td&#x3E;
  1463.                &#x3C;/tr&#x3E;
  1464. &#x9;&#x9;&#x9;&#x9;&#x3C;tr&#x3E;Shortcode um den Button manuell einzubinden: [hnp_cwc_button]&#x3C;/tr&#x3E;
  1465.            &#x3C;/table&#x3E;
  1466.            &#x3C;?php submit_button(); ?&#x3E;
  1467.        &#x3C;/form&#x3E;
  1468.    &#x3C;/div&#x3E;
  1469.    &#x3C;?php
  1470. }
  1471.  
  1472. </pre>
  1473. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/15/woocommerce-warenkorb-leeren-session-button/">WooCommerce Warenkorb Leeren &#038; Session Button</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1474. ]]></content:encoded>
  1475. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/15/woocommerce-warenkorb-leeren-session-button/feed/</wfw:commentRss>
  1476. <slash:comments>0</slash:comments>
  1477. </item>
  1478. <item>
  1479. <title>HNP Empty Plugin &#8211; WordPress Demo Code</title>
  1480. <link>https://homepage-nach-preis.de/2024/04/10/hnp-empty-plugin-wordpress-demo-code/</link>
  1481. <comments>https://homepage-nach-preis.de/2024/04/10/hnp-empty-plugin-wordpress-demo-code/#respond</comments>
  1482. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  1483. <pubDate>Wed, 10 Apr 2024 13:54:30 +0000</pubDate>
  1484. <category><![CDATA[Allgemein]]></category>
  1485. <category><![CDATA[Wordpress Code]]></category>
  1486. <category><![CDATA[Beispiel]]></category>
  1487. <category><![CDATA[Code]]></category>
  1488. <category><![CDATA[Demo]]></category>
  1489. <category><![CDATA[Empty]]></category>
  1490. <category><![CDATA[Leeres]]></category>
  1491. <category><![CDATA[plugin]]></category>
  1492. <category><![CDATA[wordpress]]></category>
  1493. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8186</guid>
  1494.  
  1495. <description><![CDATA[<p>Das HNP Empty Plugin ist ein einfaches Demo-Plugin für WordPress, das entwickelt wurde, um grundlegende Funktionen eines Plugins zu demonstrieren. Es zeigt, wie man Styles und Skripte sowohl im Frontend als auch im Backend von WordPress einbindet. Außerdem bietet es eine Benutzeroberfläche zur Verwaltung von Plugin-Optionen über das WordPress-Dashboard. Der Plugin-Demo Code besitzt alle wichtigen Sicherheitsoptionen und Code-Qualitätsanforderungen, damit ein Plugin im offiziellen WordPress Verzeichnis aufgenommen wird. Zudem Funktionen, welche im Jahr 2024 auf dem neuesten Stand sind. Somit eine gute Grundlage für WordPress-Plugin-Entwickler. Geteste Kompatibilität: WordPress 6.5.2 und PHP 8.3. Das Plugin wird aber auch mit neueren und älteren PHP und WordPress Versionen kompatibel sein. Features: Frontend und Backend Styling: Das Plugin fügt sowohl dem Frontend als auch dem Backend von WordPress benutzerdefinierte CSS- und JavaScript-Dateien hinzu, um das Erscheinungsbild anzupassen. Plugin-Optionen: Es bietet eine einfache Möglichkeit, Plugin-Optionen über das WordPress-Dashboard zu konfigurieren, einschließlich Textfelder, Zahlenfelder, Farbwähler, Dropdown-Listen und Checkboxen. Shortcode: Das Plugin stellt einen Shortcode bereit, mit dem Benutzer die konfigurierten Optionen auf beliebigen Seiten oder Beiträgen anzeigen können. Sicherheitsmaßnahmen: Das Plugin implementiert Sicherheitsmaßnahmen wie Nonce-Überprüfung, um unerwünschte Zugriffe auf die Plugin-Einstellungen zu verhindern. &#160; Plugin-Download: [sdm_download id=&#8221;8187&#8243; fancy=&#8221;0&#8243;] Github: https://github.com/HNP-Christopher-Rohde/hnp_empty_wordpress_plugin Quellcode: &#60;?php /* Plugin Name: HNP Empty....</p>
  1496. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/10/hnp-empty-plugin-wordpress-demo-code/">HNP Empty Plugin &#8211; WordPress Demo Code</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1497. ]]></description>
  1498. <content:encoded><![CDATA[<p>Das HNP Empty Plugin ist ein einfaches Demo-Plugin für WordPress, das entwickelt wurde, um grundlegende Funktionen eines Plugins zu demonstrieren. Es zeigt, wie man Styles und Skripte sowohl im Frontend als auch im Backend von WordPress einbindet. Außerdem bietet es eine Benutzeroberfläche zur Verwaltung von Plugin-Optionen über das WordPress-Dashboard. Der Plugin-Demo Code besitzt alle wichtigen Sicherheitsoptionen und Code-Qualitätsanforderungen, damit ein Plugin im offiziellen WordPress Verzeichnis aufgenommen wird. Zudem Funktionen, welche im Jahr 2024 auf dem neuesten Stand sind. Somit eine gute Grundlage für WordPress-Plugin-Entwickler. Geteste Kompatibilität: WordPress 6.5.2 und PHP 8.3. Das Plugin wird aber auch mit neueren und älteren PHP und WordPress Versionen kompatibel sein. </p>
  1499. <p><strong>Features:</strong></p>
  1500. <ul>
  1501. <li><strong>Frontend und Backend Styling:</strong> Das Plugin fügt sowohl dem Frontend als auch dem Backend von WordPress benutzerdefinierte CSS- und JavaScript-Dateien hinzu, um das Erscheinungsbild anzupassen.</li>
  1502. <li><strong>Plugin-Optionen:</strong> Es bietet eine einfache Möglichkeit, Plugin-Optionen über das WordPress-Dashboard zu konfigurieren, einschließlich Textfelder, Zahlenfelder, Farbwähler, Dropdown-Listen und Checkboxen.</li>
  1503. <li><strong>Shortcode:</strong> Das Plugin stellt einen Shortcode bereit, mit dem Benutzer die konfigurierten Optionen auf beliebigen Seiten oder Beiträgen anzeigen können.</li>
  1504. <li><strong>Sicherheitsmaßnahmen:</strong> Das Plugin implementiert Sicherheitsmaßnahmen wie Nonce-Überprüfung, um unerwünschte Zugriffe auf die Plugin-Einstellungen zu verhindern.</li>
  1505. </ul>
  1506. <p>&nbsp;</p>
  1507. <p><strong>Plugin-Download:</strong> [sdm_download id=&#8221;8187&#8243; fancy=&#8221;0&#8243;]<br />
  1508. <strong>Github:</strong> <a href="https://github.com/HNP-Christopher-Rohde/hnp_empty_wordpress_plugin" target="_blank" rel="nofollow noopener">https://github.com/HNP-Christopher-Rohde/hnp_empty_wordpress_plugin</a><br />
  1509. <strong>Quellcode:</strong></p>
  1510. <pre>&lt;?php
  1511. /*
  1512.  Plugin Name: HNP Empty Plugin
  1513.  Description: Creates a Demo Plugin in WordPress
  1514.  Version: 2.0
  1515.  Author: HNP C.R.
  1516.  Author URI: https://homepage-nach-preis.de/
  1517.  License: GPLv3
  1518.  License URI: https://www.gnu.org/licenses/gpl-3.0.html
  1519. */
  1520.  
  1521. // Security check to prevent direct access to the plugin file
  1522. defined('ABSPATH') or die('No script kiddies please!');
  1523.  
  1524. // Function to enqueue the Frontend CSS and JS
  1525. function hnp_empty_plugin_frontend_scripts() {
  1526.    // Define a version number
  1527.    $version = '2.0';
  1528.  
  1529.    // Check if CSS is not already enqueued
  1530.    if (!wp_style_is('hnp_empty_plugin_frontend-css')) {
  1531.        // Enqueue CSS with the defined version
  1532.        wp_enqueue_style('hnp_empty_plugin_frontend-css', plugin_dir_url(__FILE__) . '/frontend/css/hnp_empty_plugin_frontend.css', array(), $version);
  1533.    }
  1534.  
  1535.    // Check if JavaScript is not already enqueued
  1536.    if (!wp_script_is('hnp_empty_plugin_frontend-js')) {
  1537.        // Enqueue JavaScript with the defined version
  1538.        wp_enqueue_script('hnp_empty_plugin_frontend-js', plugin_dir_url(__FILE__) . '/frontend/js/hnp_empty_plugin_frontend.js', array(), $version, true);
  1539.    }
  1540. }
  1541. add_action('wp_enqueue_scripts', 'hnp_empty_plugin_frontend_scripts');
  1542.  
  1543. // Function to enqueue Backend CSS and JS
  1544. function hnp_empty_plugin_backend_scripts() {
  1545.    // Define a version number
  1546.    $version = '2.0';
  1547.  
  1548.    // Check if CSS is not already enqueued
  1549.    if (!wp_style_is('hnp_empty_plugin_backend-css')) {
  1550.        // Enqueue CSS with the defined version
  1551.        wp_enqueue_style('hnp_empty_plugin_backend-css', plugin_dir_url(__FILE__) . '/backend/css/hnp_empty_plugin_backend.css', array(), $version);
  1552.    }
  1553.  
  1554.    // Check if JavaScript is not already enqueued
  1555.    if (!wp_script_is('hnp_empty_plugin_backend-js')) {
  1556.        // Enqueue JavaScript with the defined version
  1557.        wp_enqueue_script('hnp_empty_plugin_backend-js', plugin_dir_url(__FILE__) . '/backend/js/hnp_empty_plugin_backend.js', array(), $version, true);
  1558.    }
  1559. }
  1560. add_action('admin_enqueue_scripts', 'hnp_empty_plugin_backend_scripts');
  1561.  
  1562. // Function for Test - with load Options and Fallback
  1563. function hnp_empty_plugin_echo_func() {
  1564.    // Get option values
  1565.    $name = get_option('hnp_empty_plugin_name_field', 'Name');
  1566.    $number = get_option('hnp_empty_plugin_number_field', '12');
  1567.    $color = get_option('hnp_empty_plugin_color_field', '#ff0000');
  1568.    $description = get_option('hnp_empty_plugin_description_field', 'Im a Desc Field');
  1569.    $dropdown = get_option('hnp_empty_plugin_dropdown_field', 'option1');
  1570.    $checkbox = get_option('hnp_empty_plugin_checkbox_field', 0);
  1571.  
  1572.    // Echo option values
  1573.    echo '&lt;p&gt;Name Field: ' . esc_html($name) . '&lt;/p&gt;';
  1574.    echo '&lt;p&gt;Number Field: ' . esc_html($number) . '&lt;/p&gt;';
  1575.    echo '&lt;p&gt;Color Field: ' . esc_html($color) . '&lt;/p&gt;';
  1576.    echo '&lt;p&gt;Description Field: ' . esc_html($description) . '&lt;/p&gt;';
  1577.    echo '&lt;p&gt;Dropdown Field: ' . esc_html($dropdown) . '&lt;/p&gt;';
  1578.    echo '&lt;p&gt;Checkbox Field: ' . ($checkbox ? 'Enabled' : 'Disabled') . '&lt;/p&gt;';
  1579. }
  1580. add_shortcode('hnp_empty_plugin_echo_func', 'hnp_empty_plugin_echo_func');
  1581.  
  1582.  
  1583. // Function to add plugin options to the main menu
  1584. function hnp_empty_plugin_add_plugin_options_page() {
  1585.    // Check permission
  1586.    if (current_user_can('manage_options')) {
  1587.        add_menu_page(
  1588.            'HNP Empty Plugin Settings',
  1589.            'HNP Empty Plugin',
  1590.            'manage_options',
  1591.            'hnp-empty-plugin-settings',
  1592.            'hnp_empty_plugin_render_plugin_options_page',
  1593.            plugin_dir_url(__FILE__) . 'img/hnp-favi.png'
  1594.        );
  1595.    }
  1596. }
  1597. add_action('admin_menu', 'hnp_empty_plugin_add_plugin_options_page');
  1598.  
  1599.  
  1600. // Function to render plugin options page
  1601. function hnp_empty_plugin_render_plugin_options_page() {
  1602.    ?&gt;
  1603.    &lt;div class="wrap hnp-empty-plugin-settings"&gt;
  1604.        &lt;h1&gt;HNP Empty Plugin Settings&lt;/h1&gt;
  1605.        &lt;form method="post" action="options.php"&gt;
  1606.            &lt;?php settings_fields('hnp_empty_plugin_settings_group'); ?&gt;
  1607.            &lt;?php do_settings_sections('hnp-empty-plugin-settings'); ?&gt;
  1608.            
  1609.            &lt;?php
  1610.                // Add nonce
  1611.                wp_nonce_field('hnp_empty_plugin_settings_nonce', 'hnp_empty_plugin_settings_nonce');
  1612.            ?&gt;
  1613.            
  1614.            &lt;?php submit_button(); ?&gt;
  1615.        &lt;/form&gt;
  1616.    &lt;/div&gt;
  1617.    &lt;?php
  1618. }
  1619.  
  1620. // Function to register plugin options
  1621. function hnp_empty_plugin_register_plugin_options() {
  1622.    // Name
  1623.    add_settings_section(
  1624.        'hnp_empty_plugin_name_section',
  1625.        'Demo',
  1626.        'hnp_empty_plugin_demo_section_callback',
  1627.        'hnp-empty-plugin-settings'
  1628.    );
  1629.  
  1630.    // Name
  1631.    add_settings_field(
  1632.        'hnp_empty_plugin_name_field',
  1633.        'Name Field',
  1634.        'hnp_empty_plugin_name_field_callback',
  1635.        'hnp-empty-plugin-settings',
  1636.        'hnp_empty_plugin_name_section'
  1637.    );
  1638.  
  1639.    // Number
  1640.    add_settings_field(
  1641.        'hnp_empty_plugin_number_field',
  1642.        'Number Field',
  1643.        'hnp_empty_plugin_number_field_callback',
  1644.        'hnp-empty-plugin-settings',
  1645.        'hnp_empty_plugin_name_section'
  1646.    );
  1647.  
  1648.    // Color
  1649.    add_settings_field(
  1650.        'hnp_empty_plugin_color_field',
  1651.        'Color Field',
  1652.        'hnp_empty_plugin_color_field_callback',
  1653.        'hnp-empty-plugin-settings',
  1654.        'hnp_empty_plugin_name_section'
  1655.    );
  1656.  
  1657.    // Description
  1658.    add_settings_field(
  1659.        'hnp_empty_plugin_description_field',
  1660.        'Description Field',
  1661.        'hnp_empty_plugin_description_field_callback',
  1662.        'hnp-empty-plugin-settings',
  1663.        'hnp_empty_plugin_name_section'
  1664.    );
  1665.  
  1666.    // Dropdown
  1667.    add_settings_field(
  1668.        'hnp_empty_plugin_dropdown_field',
  1669.        'Dropdown Field',
  1670.        'hnp_empty_plugin_dropdown_field_callback',
  1671.        'hnp-empty-plugin-settings',
  1672.        'hnp_empty_plugin_name_section'
  1673.    );
  1674.  
  1675.    // Checkbox
  1676.    add_settings_field(
  1677.        'hnp_empty_plugin_checkbox_field',
  1678.        'Checkbox Field',
  1679.        'hnp_empty_plugin_checkbox_field_callback',
  1680.        'hnp-empty-plugin-settings',
  1681.        'hnp_empty_plugin_name_section'
  1682.    );
  1683. }
  1684. add_action('admin_init', 'hnp_empty_plugin_register_plugin_options');
  1685. </pre>
  1686. <pre>
  1687. // Callback function for demo section
  1688. function hnp_empty_plugin_demo_section_callback() {
  1689.    echo 'This a Demo Plugin. Frontend-Shortcode: &amp;#x5B;hnp_empty_plugin_echo_func]&lt;/p&gt;';
  1690. }
  1691.  
  1692. // Callback function for name field
  1693. function hnp_empty_plugin_name_field_callback() {
  1694.    $value = get_option('hnp_empty_plugin_name_field', 'Name'); // Fallback value is 'Name'
  1695.    echo '&lt;input type="text" name="hnp_empty_plugin_name_field" value="' . esc_attr($value) . '" /&gt;';
  1696. }
  1697.  
  1698. // Callback functions for number fields
  1699. function hnp_empty_plugin_number_field_callback() {
  1700.    $value = get_option('hnp_empty_plugin_number_field', '12'); // Fallback value is '12'
  1701.    echo '&lt;input type="number" name="hnp_empty_plugin_number_field" value="' . esc_attr($value) . '" /&gt;';
  1702. }
  1703.  
  1704. // Callback function for Color Field
  1705. function hnp_empty_plugin_color_field_callback() {
  1706.    $value = get_option('hnp_empty_plugin_color_field', '#ff0000'); // Fallback value is red color
  1707.    echo '&lt;input type="color" name="hnp_empty_plugin_color_field" value="' . esc_attr($value) . '" /&gt;';
  1708. }
  1709.  
  1710. // Callback function for Description Field
  1711. function hnp_empty_plugin_description_field_callback() {
  1712.    $value = get_option('hnp_empty_plugin_description_field', 'Im a Desc Field'); // Fallback value is 'Im a Desc Field'
  1713.    echo '&lt;textarea name="hnp_empty_plugin_description_field"&gt;' . esc_html($value) . '&lt;/textarea&gt;';
  1714. }
  1715.  
  1716. // Callback function for dropdown field
  1717. function hnp_empty_plugin_dropdown_field_callback() {
  1718.    $value = get_option('hnp_empty_plugin_dropdown_field', 'option1'); // Fallback value is 'option1'
  1719.    ?&gt;
  1720.    &lt;select name="hnp_empty_plugin_dropdown_field"&gt;
  1721.        &lt;option value="option1" &lt;?php selected($value, 'option1'); ?&gt;&gt;Option 1&lt;/option&gt;
  1722.        &lt;option value="option2" &lt;?php selected($value, 'option2'); ?&gt;&gt;Option 2&lt;/option&gt;
  1723.        &lt;option value="option3" &lt;?php selected($value, 'option3'); ?&gt;&gt;Option 3&lt;/option&gt;
  1724.    &lt;/select&gt;
  1725.    &lt;?php
  1726. }
  1727.  
  1728. // Callback function for checkbox field
  1729. function hnp_empty_plugin_checkbox_field_callback() {
  1730.    $value = get_option('hnp_empty_plugin_checkbox_field', 0); // Fallback value is 0 (not checked)
  1731.    ?&gt;
  1732.    &lt;label for="hnp_empty_plugin_checkbox_field"&gt;
  1733.        &lt;input type="checkbox" name="hnp_empty_plugin_checkbox_field" id="hnp_empty_plugin_checkbox_field" value="1" &lt;?php checked($value, 1); ?&gt;&gt;
  1734.        Enable Checkbox
  1735.    &lt;/label&gt;
  1736.    &lt;?php
  1737. }
  1738.  
  1739. // Security measures: Nonce verification and save options
  1740. function hnp_empty_plugin_register_security_options() {
  1741.    // Check if the current page is our plugin options page
  1742.    if (isset($_POST['option_page']) &amp;&amp; $_POST['option_page'] == 'hnp_empty_plugin_settings_group') {
  1743.        // Check if the nonce is set and valid
  1744.        if (!isset($_POST['hnp_empty_plugin_settings_nonce']) || !wp_verify_nonce($_POST['hnp_empty_plugin_settings_nonce'], 'hnp_empty_plugin_settings_nonce')) {
  1745.            // Unauthorized request, do not save options
  1746.            wp_die('Unauthorized request.'); // Output error message for unauthorized requests
  1747.        }
  1748.  
  1749.        // Save options
  1750.        update_option('hnp_empty_plugin_name_field', $_POST['hnp_empty_plugin_name_field']);
  1751.        update_option('hnp_empty_plugin_number_field', sanitize_text_field($_POST['hnp_empty_plugin_number_field']));
  1752.        update_option('hnp_empty_plugin_color_field', sanitize_text_field($_POST['hnp_empty_plugin_color_field']));
  1753.        update_option('hnp_empty_plugin_description_field', sanitize_textarea_field($_POST['hnp_empty_plugin_description_field']));
  1754.        update_option('hnp_empty_plugin_dropdown_field', sanitize_text_field($_POST['hnp_empty_plugin_dropdown_field']));
  1755.        update_option('hnp_empty_plugin_checkbox_field', isset($_POST['hnp_empty_plugin_checkbox_field']) ? 1 : 0);
  1756.    }
  1757. }
  1758. add_action('admin_init', 'hnp_empty_plugin_register_security_options');
  1759.  
  1760. // Register plugin options and security measures
  1761. function hnp_empty_plugin_register_settings() {
  1762.    // Register setting and sanitize callback
  1763.    register_setting('hnp_empty_plugin_settings_group', 'hnp_empty_plugin_name_field');
  1764.    register_setting('hnp_empty_plugin_settings_group', 'hnp_empty_plugin_number_field');
  1765.    register_setting('hnp_empty_plugin_settings_group', 'hnp_empty_plugin_color_field');
  1766.    register_setting('hnp_empty_plugin_settings_group', 'hnp_empty_plugin_description_field');
  1767.    register_setting('hnp_empty_plugin_settings_group', 'hnp_empty_plugin_dropdown_field');
  1768.    register_setting('hnp_empty_plugin_settings_group', 'hnp_empty_plugin_checkbox_field');
  1769. }
  1770. add_action('admin_init', 'hnp_empty_plugin_register_settings');
  1771.  
  1772.  
  1773. // Security measures: Nonce verification for options update
  1774. function hnp_empty_plugin_validate_settings($input) {
  1775.    return $input; // Simply return the input, no further validation here
  1776. }
  1777.  
  1778. </pre>
  1779. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/10/hnp-empty-plugin-wordpress-demo-code/">HNP Empty Plugin &#8211; WordPress Demo Code</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1780. ]]></content:encoded>
  1781. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/10/hnp-empty-plugin-wordpress-demo-code/feed/</wfw:commentRss>
  1782. <slash:comments>0</slash:comments>
  1783. </item>
  1784. <item>
  1785. <title>HNP OpenStreetMap kostenloses Plugin</title>
  1786. <link>https://homepage-nach-preis.de/2024/04/10/hnp-openstreetmap-kostenloses-plugin/</link>
  1787. <comments>https://homepage-nach-preis.de/2024/04/10/hnp-openstreetmap-kostenloses-plugin/#respond</comments>
  1788. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  1789. <pubDate>Wed, 10 Apr 2024 10:19:20 +0000</pubDate>
  1790. <category><![CDATA[Allgemein]]></category>
  1791. <category><![CDATA[Homepage]]></category>
  1792. <category><![CDATA[Wordpress Code]]></category>
  1793. <category><![CDATA[Karte]]></category>
  1794. <category><![CDATA[kostenlos]]></category>
  1795. <category><![CDATA[Openmaps]]></category>
  1796. <category><![CDATA[OpenStreetMap]]></category>
  1797. <category><![CDATA[plugin]]></category>
  1798. <category><![CDATA[Shortcode]]></category>
  1799. <category><![CDATA[wordpress]]></category>
  1800. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8176</guid>
  1801.  
  1802. <description><![CDATA[<p>Das &#8220;HNP OpenStreetMap Shortcode&#8221; Plugin ermöglicht es Benutzern, OpenStreetMap-Karten mit einem Pin direkt auf ihrer WordPress-Website einzubetten, indem sie einen Shortcode verwenden. Es bietet eine einfache Möglichkeit, einen Standort auf einer interaktiven Karte zu markieren. &#160; Hier sind die Hauptmerkmale des Plugins: Shortcode-Unterstützung: Benutzer können den bereitgestellten Shortcode verwenden, um eine Karte mit einem Pin an einem bestimmten Standort anzuzeigen. Anpassbare Optionen: Das Plugin bietet verschiedene anpassbare Optionen, darunter die Möglichkeit, die Adresse des Pins, den Namen des Markers, den Zoomlevel der Karte, den Kartenstil sowie die Höhe und Breite der Karte anzupassen. Integrierte Sicherheitsmaßnahmen: Das Plugin enthält Sicherheitsmaßnahmen wie Nonce-Überprüfung, um unautorisierte Zugriffe auf die Plugin-Optionen zu verhindern und die Datenintegrität zu gewährleisten. Einfache Konfiguration: Benutzer können die Plugin-Optionen über das WordPress-Adminpanel konfigurieren, um ihre Karten entsprechend ihren Anforderungen anzupassen. Das Plugin wurde von Homepage-nach-Preis.de entwickelt und steht unter der GNU General Public License Version 3 (GPLv3), was bedeutet, dass es kostenlos verwendet und modifiziert werden kann, solange die Lizenzbedingungen eingehalten werden. Download: [sdm_download id=&#8221;8174&#8243; fancy=&#8221;0&#8243;] Github: https://github.com/HNP-Christopher-Rohde/hnp-openstreetmap-wordpress-plugin/tree/main/hnp_openstreetmap Quellcode: &#x3C;?php /* Plugin Name: HNP OpenStreetMap Shortcode Description: Creates a frontend OpenStreetMap map with a pin using a shortcode Version: 1.0 Author: HNP - C.R. Author URI: https://homepage-nach-preis.de/ License: GPLv3....</p>
  1803. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/10/hnp-openstreetmap-kostenloses-plugin/">HNP OpenStreetMap kostenloses Plugin</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  1804. ]]></description>
  1805. <content:encoded><![CDATA[<p>Das &#8220;HNP OpenStreetMap Shortcode&#8221; Plugin ermöglicht es Benutzern, OpenStreetMap-Karten mit einem Pin direkt auf ihrer WordPress-Website einzubetten, indem sie einen Shortcode verwenden. Es bietet eine einfache Möglichkeit, einen Standort auf einer interaktiven Karte zu markieren.</p>
  1806. <p>&nbsp;</p>
  1807. <p>Hier sind die Hauptmerkmale des Plugins:</p>
  1808. <ol>
  1809. <li><strong>Shortcode-Unterstützung:</strong> Benutzer können den bereitgestellten Shortcode verwenden, um eine Karte mit einem Pin an einem bestimmten Standort anzuzeigen.</li>
  1810. <li><strong>Anpassbare Optionen:</strong> Das Plugin bietet verschiedene anpassbare Optionen, darunter die Möglichkeit, die Adresse des Pins, den Namen des Markers, den Zoomlevel der Karte, den Kartenstil sowie die Höhe und Breite der Karte anzupassen.</li>
  1811. <li><strong>Integrierte Sicherheitsmaßnahmen:</strong> Das Plugin enthält Sicherheitsmaßnahmen wie Nonce-Überprüfung, um unautorisierte Zugriffe auf die Plugin-Optionen zu verhindern und die Datenintegrität zu gewährleisten.</li>
  1812. <li><strong>Einfache Konfiguration:</strong> Benutzer können die Plugin-Optionen über das WordPress-Adminpanel konfigurieren, um ihre Karten entsprechend ihren Anforderungen anzupassen.</li>
  1813. </ol>
  1814. <p>Das Plugin wurde von Homepage-nach-Preis.de entwickelt und steht unter der GNU General Public License Version 3 (GPLv3), was bedeutet, dass es kostenlos verwendet und modifiziert werden kann, solange die Lizenzbedingungen eingehalten werden.</p>
  1815. <p><strong>Download:</strong> [sdm_download id=&#8221;8174&#8243; fancy=&#8221;0&#8243;]</p>
  1816. <p><strong>Github:</strong> <a href="https://github.com/HNP-Christopher-Rohde/hnp-openstreetmap-wordpress-plugin/tree/main/hnp_openstreetmap" target="_blank" rel="nofollow noopener">https://github.com/HNP-Christopher-Rohde/hnp-openstreetmap-wordpress-plugin/tree/main/hnp_openstreetmap</a><br />
  1817. <strong>Quellcode:</strong></p>
  1818. <pre>
  1819. &#x3C;?php
  1820. /*
  1821.  Plugin Name: HNP OpenStreetMap Shortcode
  1822.  Description: Creates a frontend OpenStreetMap map with a pin using a shortcode
  1823.  Version: 1.0
  1824.  Author: HNP - C.R.
  1825.  Author URI: https://homepage-nach-preis.de/
  1826.  License: GPLv3
  1827.  License URI: https://www.gnu.org/licenses/gpl-3.0.html
  1828. */
  1829.  
  1830. // Security check to prevent direct access to the plugin file
  1831. defined(&#x27;ABSPATH&#x27;) or die(&#x27;No script kiddies please!&#x27;);
  1832.  
  1833. // Function to enqueue Leaflet library
  1834. function hnp_openmaps_enqueue_leaflet_scripts() {
  1835.    // Define a version number for your CSS file
  1836.    $version = &#x27;1.9.4&#x27;;
  1837.  
  1838.    // Check if Leaflet CSS is not already enqueued
  1839.    if (!wp_style_is(&#x27;leaflet-css&#x27;)) {
  1840.        // Enqueue Leaflet CSS with the defined version
  1841.        wp_enqueue_style(&#x27;leaflet-css&#x27;, plugin_dir_url(__FILE__) . &#x27;leaflet/leaflet.css&#x27;, array(), $version);
  1842.    }
  1843.  
  1844.    // Check if Leaflet JavaScript is not already enqueued
  1845.    if (!wp_script_is(&#x27;leaflet-js&#x27;)) {
  1846.        // Enqueue Leaflet JavaScript with the defined version
  1847.        wp_enqueue_script(&#x27;leaflet-js&#x27;, plugin_dir_url(__FILE__) . &#x27;leaflet/leaflet.js&#x27;, array(), $version, true);
  1848.    }
  1849. }
  1850. add_action(&#x27;wp_enqueue_scripts&#x27;, &#x27;hnp_openmaps_enqueue_leaflet_scripts&#x27;);
  1851.  
  1852. // Function to display OpenStreetMap maps with a pin
  1853. function hnp_openmaps_display_map_with_pin() {
  1854.    // Load options and sanitize address
  1855.    $raw_address = get_option(&#x27;hnp_openmaps_map_address&#x27;, &#x27;Hardenbergpl. 8, 10787 Berlin, Germany&#x27;);
  1856.    $clean_address = sanitize_text_field($raw_address);
  1857.  
  1858.    // Load options and sanitize marker name
  1859.    $marker_name = get_option(&#x27;hnp_openmaps_map_name&#x27;, &#x27;Berlin Zoological Garden&#x27;);
  1860.  
  1861.    // Load zoom level, map style, height, and width of the map
  1862.    $zoom = get_option(&#x27;hnp_openmaps_map_zoom&#x27;, 12);
  1863.    $style = get_option(&#x27;hnp_openmaps_map_style&#x27;, &#x27;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&#x27;);
  1864.    $height = get_option(&#x27;hnp_openmaps_map_height&#x27;, &#x27;400px&#x27;);
  1865.    $width = get_option(&#x27;hnp_openmaps_map_width&#x27;, &#x27;100%&#x27;);
  1866.  
  1867.    // JavaScript variable for map initialization and adding markers
  1868.    $map = &#x22;
  1869.        &#x3C;script&#x3E;
  1870.            document.addEventListener(&#x27;DOMContentLoaded&#x27;, function() {
  1871.    &#x22;;
  1872.  
  1873.    // Split address into individual parts and encode
  1874.    $address_parts = explode(&#x27;,&#x27;, $clean_address);
  1875.    $encoded_address_parts = array_map(&#x27;urlencode&#x27;, $address_parts);
  1876.    $encoded_address = implode(&#x27;,&#x27;, $encoded_address_parts);
  1877.  
  1878.    // Construct Nominatim URL
  1879.    $nominatim_url = &#x22;https://nominatim.openstreetmap.org/search?format=json&#x26;q={$encoded_address}&#x22;;
  1880.  
  1881.    // Get geocoding data from Nominatim
  1882.    $response = wp_remote_get($nominatim_url);
  1883.  
  1884.    // Check if the request was successful
  1885.    if (!is_wp_error($response) &#x26;&#x26; wp_remote_retrieve_response_code($response) === 200) {
  1886.        $data = json_decode(wp_remote_retrieve_body($response), true);
  1887.  
  1888.        // Check if geocoding results were obtained
  1889.        if (!empty($data)) {
  1890.            $latitude = $data[0][&#x27;lat&#x27;];
  1891.            $longitude = $data[0][&#x27;lon&#x27;];
  1892.  
  1893.            // Initialize map with center at marker coordinates
  1894.            $map .= &#x22;
  1895.                var hnp_openmaps_map = L.map(&#x27;hnp_openmaps_map&#x27;).setView([$latitude, $longitude], $zoom);
  1896.            &#x22;;
  1897.  
  1898.            // Add tiles to the map
  1899.            $map .= &#x22;
  1900.                L.tileLayer(&#x27;$style&#x27;, {
  1901.                    attribution: &#x27;&#x26;copy; &#x3C;a href=\&#x22;https://www.openstreetmap.org/copyright\&#x22;&#x3E;OpenStreetMap&#x3C;/a&#x3E; contributors&#x27;
  1902.                }).addTo(hnp_openmaps_map);
  1903.            &#x22;;
  1904.  
  1905.            // Add marker to the map
  1906.            $map .= &#x22;
  1907.                L.marker([$latitude, $longitude]).addTo(hnp_openmaps_map).bindPopup(&#x27;&#x22; . esc_js($clean_address) . &#x22;&#x27;).bindTooltip(&#x27;&#x22; . esc_js($marker_name) . &#x22;&#x27;);
  1908.                console.log(&#x27;Geocoding successful for address:&#x27;, &#x22; . wp_json_encode($clean_address) . &#x22;);
  1909.            &#x22;;
  1910.        } else {
  1911.            // Error retrieving geocoding data
  1912.            error_log(&#x22;Error retrieving geocoding data for address: $clean_address&#x22;);
  1913.            $map .= &#x22;
  1914.                console.log(&#x27;Error retrieving geocoding data for address:&#x27;, &#x22; . wp_json_encode($clean_address) . &#x22;);
  1915.            &#x22;;
  1916.        }
  1917.    } else {
  1918.        // Error retrieving geocoding data
  1919.        error_log(&#x22;Error retrieving geocoding data for address: $clean_address&#x22;);
  1920.        $map .= &#x22;
  1921.            console.log(&#x27;Error retrieving geocoding data for address:&#x27;, &#x22; . wp_json_encode($clean_address) . &#x22;);
  1922.        &#x22;;
  1923.    }
  1924.  
  1925.    // Add JavaScript end
  1926.    $map .= &#x22;
  1927.            });
  1928.        &#x3C;/script&#x3E;
  1929.    &#x22;;
  1930.  
  1931.    // Return map div and JavaScript
  1932.    return &#x27;&#x3C;div id=&#x22;hnp_openmaps_map&#x22; style=&#x22;height: &#x27; . esc_attr($height) . &#x27;; width: &#x27; . esc_attr($width) . &#x27;;&#x22;&#x3E;&#x3C;/div&#x3E;&#x27; . $map;
  1933. }
  1934.  
  1935. // Register shortcode
  1936. add_shortcode(&#x27;hnp_openmaps_display_map_with_pin&#x27;, &#x27;hnp_openmaps_display_map_with_pin&#x27;);
  1937.  
  1938. // Function to add plugin options to the main menu
  1939. function hnp_openmaps_add_plugin_options_page() {
  1940.    // Check permission
  1941.    if (current_user_can(&#x27;manage_options&#x27;)) {
  1942.        add_menu_page(
  1943.            &#x27;HNP OpenStreetMap Settings&#x27;,
  1944.            &#x27;HNP OpenStreetMap&#x27;,
  1945.            &#x27;manage_options&#x27;,
  1946.            &#x27;hnp-openmaps-osm-settings&#x27;,
  1947.            &#x27;hnp_openmaps_render_plugin_options_page&#x27;,
  1948.            plugin_dir_url(__FILE__) . &#x27;img/hnp-favi.png&#x27;
  1949.        );
  1950.    }
  1951. }
  1952. add_action(&#x27;admin_menu&#x27;, &#x27;hnp_openmaps_add_plugin_options_page&#x27;);
  1953.  
  1954. // Add settings link to plugin on the Plugins page
  1955. function hnp_openmaps_add_settings_link($links) {
  1956.    $settings_link = &#x27;&#x3C;a href=&#x22;admin.php?page=hnp-openmaps-osm-settings&#x22;&#x3E;&#x27; . __(&#x27;Settings&#x27;) . &#x27;&#x3C;/a&#x3E;&#x27;;
  1957.    array_unshift($links, $settings_link); // Add the settings link at the beginning of the array
  1958.    return $links;
  1959. }
  1960. add_filter(&#x27;plugin_action_links_&#x27; . plugin_basename(__FILE__), &#x27;hnp_openmaps_add_settings_link&#x27;);
  1961.  
  1962.  
  1963. // Function to render plugin options page
  1964. function hnp_openmaps_render_plugin_options_page() {
  1965.    ?&#x3E;
  1966.    &#x3C;div class=&#x22;wrap&#x22;&#x3E;
  1967.        &#x3C;h1&#x3E;HNP OpenStreetMap Settings&#x3C;/h1&#x3E;
  1968.        &#x3C;form method=&#x22;post&#x22; action=&#x22;options.php&#x22;&#x3E;
  1969.            &#x3C;?php settings_fields(&#x27;hnp_openmaps_osm_settings_group&#x27;); ?&#x3E;
  1970.            &#x3C;?php do_settings_sections(&#x27;hnp-openmaps-osm-settings&#x27;); ?&#x3E;
  1971.            &#x3C;?php
  1972.                // Add nonce
  1973.                wp_nonce_field(&#x27;hnp_openmaps_osm_settings_nonce&#x27;, &#x27;hnp_openmaps_osm_settings_nonce&#x27;);
  1974.            ?&#x3E;
  1975.            &#x3C;?php submit_button(); ?&#x3E;
  1976.        &#x3C;/form&#x3E;
  1977.    &#x3C;/div&#x3E;
  1978.    &#x3C;?php
  1979. }
  1980.  
  1981. </pre>
  1982. <pre>
  1983.  
  1984. // Function to register plugin options
  1985. function hnp_openmaps_register_plugin_options() {
  1986.    // Adresse
  1987.    add_settings_section(
  1988.        &#x27;hnp_openmaps_osm_address_section&#x27;,
  1989.        &#x27;Address&#x27;,
  1990.        &#x27;hnp_openmaps_osm_address_section_callback&#x27;,
  1991.        &#x27;hnp-openmaps-osm-settings&#x27;
  1992.    );
  1993.    add_settings_field(
  1994.        &#x27;hnp_openmaps_map_address&#x27;,
  1995.        &#x27;Address&#x27;,
  1996.        &#x27;hnp_openmaps_map_address_callback&#x27;,
  1997.        &#x27;hnp-openmaps-osm-settings&#x27;,
  1998.        &#x27;hnp_openmaps_osm_address_section&#x27;
  1999.    );
  2000.    register_setting(&#x27;hnp_openmaps_osm_settings_group&#x27;, &#x27;hnp_openmaps_map_address&#x27;);
  2001.  
  2002.    // Name
  2003.    add_settings_section(
  2004.        &#x27;hnp_openmaps_osm_name_section&#x27;,
  2005.        &#x27;Name&#x27;,
  2006.        &#x27;hnp_openmaps_osm_name_section_callback&#x27;,
  2007.        &#x27;hnp-openmaps-osm-settings&#x27;
  2008.    );
  2009.    add_settings_field(
  2010.        &#x27;hnp_openmaps_map_name&#x27;,
  2011.        &#x27;Name&#x27;,
  2012.        &#x27;hnp_openmaps_map_name_callback&#x27;,
  2013.        &#x27;hnp-openmaps-osm-settings&#x27;,
  2014.        &#x27;hnp_openmaps_osm_name_section&#x27;
  2015.    );
  2016.    register_setting(&#x27;hnp_openmaps_osm_settings_group&#x27;, &#x27;hnp_openmaps_map_name&#x27;);
  2017.  
  2018.    // Karten-Zoom
  2019.    add_settings_section(
  2020.        &#x27;hnp_openmaps_osm_zoom_section&#x27;,
  2021.        &#x27;Map Zoom&#x27;,
  2022.        &#x27;hnp_openmaps_osm_zoom_section_callback&#x27;,
  2023.        &#x27;hnp-openmaps-osm-settings&#x27;
  2024.    );
  2025.    add_settings_field(
  2026.        &#x27;hnp_openmaps_map_zoom&#x27;,
  2027.        &#x27;Map Zoom&#x27;,
  2028.        &#x27;hnp_openmaps_map_zoom_callback&#x27;,
  2029.        &#x27;hnp-openmaps-osm-settings&#x27;,
  2030.        &#x27;hnp_openmaps_osm_zoom_section&#x27;
  2031.    );
  2032.    register_setting(&#x27;hnp_openmaps_osm_settings_group&#x27;, &#x27;hnp_openmaps_map_zoom&#x27;);
  2033.  
  2034.    // Kartenstil
  2035.    add_settings_section(
  2036.        &#x27;hnp_openmaps_osm_style_section&#x27;,
  2037.        &#x27;Map Style&#x27;,
  2038.        &#x27;hnp_openmaps_osm_style_section_callback&#x27;,
  2039.        &#x27;hnp-openmaps-osm-settings&#x27;
  2040.    );
  2041.    add_settings_field(
  2042.        &#x27;hnp_openmaps_map_style&#x27;,
  2043.        &#x27;Map Style&#x27;,
  2044.        &#x27;hnp_openmaps_map_style_callback&#x27;,
  2045.        &#x27;hnp-openmaps-osm-settings&#x27;,
  2046.        &#x27;hnp_openmaps_osm_style_section&#x27;
  2047.    );
  2048.    register_setting(&#x27;hnp_openmaps_osm_settings_group&#x27;, &#x27;hnp_openmaps_map_style&#x27;);
  2049.  
  2050.    add_settings_section(
  2051.        &#x27;hnp_openmaps_osm_height_section&#x27;,
  2052.        &#x27;Map Height&#x27;,
  2053.        &#x27;hnp_openmaps_osm_height_section_callback&#x27;,
  2054.        &#x27;hnp-openmaps-osm-settings&#x27;
  2055.    );
  2056.    add_settings_field(
  2057.        &#x27;hnp_openmaps_map_height&#x27;,
  2058.        &#x27;Map Height&#x27;,
  2059.        &#x27;hnp_openmaps_map_height_callback&#x27;,
  2060.        &#x27;hnp-openmaps-osm-settings&#x27;,
  2061.        &#x27;hnp_openmaps_osm_height_section&#x27;
  2062.    );
  2063.    register_setting(&#x27;hnp_openmaps_osm_settings_group&#x27;, &#x27;hnp_openmaps_map_height&#x27;);
  2064.  
  2065.    add_settings_section(
  2066.        &#x27;hnp_openmaps_osm_width_section&#x27;,
  2067.        &#x27;Map Width&#x27;,
  2068.        &#x27;hnp_openmaps_osm_width_section_callback&#x27;,
  2069.        &#x27;hnp-openmaps-osm-settings&#x27;
  2070.    );
  2071.    add_settings_field(
  2072.        &#x27;hnp_openmaps_map_width&#x27;,
  2073.        &#x27;Map Width&#x27;,
  2074.        &#x27;hnp_openmaps_map_width_callback&#x27;,
  2075.        &#x27;hnp-openmaps-osm-settings&#x27;,
  2076.        &#x27;hnp_openmaps_osm_width_section&#x27;
  2077.    );
  2078.    register_setting(&#x27;hnp_openmaps_osm_settings_group&#x27;, &#x27;hnp_openmaps_map_width&#x27;);
  2079.  
  2080.    add_settings_section(
  2081.        &#x27;hnp_openmaps_shortcode_section&#x27;,
  2082.        &#x27;Shortcode&#x27;,
  2083.        &#x27;hnp_openmaps_shortcode_section_callback&#x27;,
  2084.        &#x27;hnp-openmaps-osm-settings&#x27;
  2085.    );
  2086. }
  2087.  
  2088. </pre>
  2089. <pre>
  2090.  
  2091. // Callback functions for each option
  2092. function hnp_openmaps_osm_address_section_callback() {
  2093.    echo &#x27;&#x3C;p&#x3E;Enter the address to be displayed on the map. &#x3C;br&#x3E;Format: Streetname + Housenumber, City Name + ZIP Code, Country &#x3C;br&#x3E;(Separate each part with a comma)&#x3C;/p&#x3E;&#x27;;
  2094. }
  2095. function hnp_openmaps_map_address_callback() {
  2096.    $address = get_option(&#x27;hnp_openmaps_map_address&#x27;, &#x27;Hardenbergpl. 8, 10787 Berlin, Germany&#x27;);
  2097.    echo &#x27;&#x3C;input type=&#x22;text&#x22; name=&#x22;hnp_openmaps_map_address&#x22; value=&#x22;&#x27; . esc_attr($address) . &#x27;&#x22; /&#x3E;&#x27;;
  2098. }
  2099.  
  2100. function hnp_openmaps_osm_name_section_callback() {
  2101.    echo &#x27;&#x3C;p&#x3E;Enter the name for the marker to be displayed on the map.&#x3C;/p&#x3E;&#x27;;
  2102. }
  2103. function hnp_openmaps_map_name_callback() {
  2104.    $name = get_option(&#x27;hnp_openmaps_map_name&#x27;, &#x27;Berlin Zoological Garden&#x27;);
  2105.    echo &#x27;&#x3C;input type=&#x22;text&#x22; name=&#x22;hnp_openmaps_map_name&#x22; value=&#x22;&#x27; . esc_attr($name) . &#x27;&#x22; /&#x3E;&#x27;;
  2106. }
  2107.  
  2108. function hnp_openmaps_osm_zoom_section_callback() {
  2109.    echo &#x27;&#x3C;p&#x3E;Set the zoom level of the map.&#x3C;/p&#x3E;&#x27;;
  2110. }
  2111. function hnp_openmaps_map_zoom_callback() {
  2112.    $zoom = get_option(&#x27;hnp_openmaps_map_zoom&#x27;, 12);
  2113.    echo &#x27;&#x3C;input type=&#x22;number&#x22; name=&#x22;hnp_openmaps_map_zoom&#x22; value=&#x22;&#x27; . esc_attr($zoom) . &#x27;&#x22; /&#x3E;&#x27;;
  2114. }
  2115. function hnp_openmaps_osm_style_section_callback() {
  2116.    echo &#x27;&#x3C;p&#x3E;Select the map style.&#x3C;/p&#x3E;&#x27;;
  2117. }
  2118. function hnp_openmaps_map_style_callback() {
  2119.    $style = get_option(&#x27;hnp_openmaps_map_style&#x27;, &#x27;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&#x27;);
  2120.    $styles = array(
  2121.        &#x27;Standard (OpenStreetMap)&#x27; =&#x3E; &#x27;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&#x27;,
  2122.        &#x27;Hot&#x27; =&#x3E; &#x27;https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png&#x27;,
  2123.        &#x27;Cycle&#x27; =&#x3E; &#x27;https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png&#x27;,
  2124.        &#x27;Transport&#x27; =&#x3E; &#x27;https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png&#x27;
  2125.        // More styles can be added here
  2126.    );
  2127.    echo &#x27;&#x3C;select name=&#x22;hnp_openmaps_map_style&#x22;&#x3E;&#x27;;
  2128.    foreach ($styles as $label =&#x3E; $url) {
  2129.        echo &#x27;&#x3C;option value=&#x22;&#x27; . esc_attr($url) . &#x27;&#x22; &#x27; . selected($style, $url, false) . &#x27;&#x3E;&#x27; . esc_html($label) . &#x27;&#x3C;/option&#x3E;&#x27;;
  2130.    }
  2131.    echo &#x27;&#x3C;/select&#x3E;&#x27;;
  2132. }
  2133.  
  2134. function hnp_openmaps_osm_height_section_callback() {
  2135.    echo &#x27;&#x3C;p&#x3E;Set the height of the map.&#x3C;/p&#x3E;&#x27;;
  2136. }
  2137. function hnp_openmaps_map_height_callback() {
  2138.    $height = get_option(&#x27;hnp_openmaps_map_height&#x27;, &#x27;400px&#x27;);
  2139.    echo &#x27;&#x3C;input type=&#x22;text&#x22; name=&#x22;hnp_openmaps_map_height&#x22; value=&#x22;&#x27; . esc_attr($height) . &#x27;&#x22; /&#x3E;&#x27;;
  2140. }
  2141. function hnp_openmaps_osm_width_section_callback() {
  2142.    echo &#x27;&#x3C;p&#x3E;Set the width of the map.&#x3C;/p&#x3E;&#x27;;
  2143. }
  2144. function hnp_openmaps_map_width_callback() {
  2145.    $width = get_option(&#x27;hnp_openmaps_map_width&#x27;, &#x27;100%&#x27;);
  2146.    echo &#x27;&#x3C;input type=&#x22;text&#x22; name=&#x22;hnp_openmaps_map_width&#x22; value=&#x22;&#x27; . esc_attr($width) . &#x27;&#x22; /&#x3E;&#x27;;
  2147. }
  2148. function hnp_openmaps_shortcode_section_callback() {
  2149.    echo &#x27;&#x3C;p&#x3E;Shortcode: &#x26;#x5B;hnp_openmaps_display_map_with_pin]&#x3C;/p&#x3E;&#x27;;
  2150. }
  2151.  
  2152. // Register plugin options and security measures
  2153. add_action(&#x27;admin_init&#x27;, &#x27;hnp_openmaps_register_plugin_options&#x27;);
  2154.  
  2155. // Security measures: Nonce verification for options update
  2156. function hnp_openmaps_validate_settings($input) {
  2157.    return $input; // Simply return the input, no further validation here
  2158. }
  2159.  
  2160. // Security measures: Nonce verification and save options
  2161. function hnp_openmaps_register_security_options() {
  2162.    // Check if the current page is our plugin options page
  2163.    if (isset($_POST[&#x27;option_page&#x27;]) &#x26;&#x26; $_POST[&#x27;option_page&#x27;] == &#x27;hnp_openmaps_osm_settings_group&#x27;) {
  2164.        // Check if the nonce is set and valid
  2165.        if (!isset($_POST[&#x27;hnp_openmaps_osm_settings_nonce&#x27;]) || !wp_verify_nonce($_POST[&#x27;hnp_openmaps_osm_settings_nonce&#x27;], &#x27;hnp_openmaps_osm_settings_nonce&#x27;)) {
  2166.            // Unauthorized request, do not save options
  2167.            wp_die(&#x27;Unauthorized request.&#x27;); // Output error message for unauthorized requests
  2168.        }
  2169.  
  2170.        // Save options
  2171.        update_option(&#x27;hnp_openmaps_map_address&#x27;, $_POST[&#x27;hnp_openmaps_map_address&#x27;]);
  2172.        update_option(&#x27;hnp_openmaps_map_name&#x27;, $_POST[&#x27;hnp_openmaps_map_name&#x27;]);
  2173.        update_option(&#x27;hnp_openmaps_map_zoom&#x27;, $_POST[&#x27;hnp_openmaps_map_zoom&#x27;]);
  2174.        update_option(&#x27;hnp_openmaps_map_style&#x27;, $_POST[&#x27;hnp_openmaps_map_style&#x27;]);
  2175.        update_option(&#x27;hnp_openmaps_map_height&#x27;, $_POST[&#x27;hnp_openmaps_map_height&#x27;]);
  2176.        update_option(&#x27;hnp_openmaps_map_width&#x27;, $_POST[&#x27;hnp_openmaps_map_width&#x27;]);
  2177.    }
  2178. }
  2179. add_action(&#x27;admin_init&#x27;, &#x27;hnp_openmaps_register_security_options&#x27;);
  2180.  
  2181. </pre>
  2182. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/10/hnp-openstreetmap-kostenloses-plugin/">HNP OpenStreetMap kostenloses Plugin</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  2183. ]]></content:encoded>
  2184. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/10/hnp-openstreetmap-kostenloses-plugin/feed/</wfw:commentRss>
  2185. <slash:comments>0</slash:comments>
  2186. </item>
  2187. <item>
  2188. <title>Dynamische Templates in WordPress erzeugen &#038; einbinden</title>
  2189. <link>https://homepage-nach-preis.de/2024/04/07/dynamische-templates-in-wordpress-erzeugen-einbinden/</link>
  2190. <comments>https://homepage-nach-preis.de/2024/04/07/dynamische-templates-in-wordpress-erzeugen-einbinden/#respond</comments>
  2191. <dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
  2192. <pubDate>Sun, 07 Apr 2024 16:20:29 +0000</pubDate>
  2193. <category><![CDATA[Webdesign]]></category>
  2194. <category><![CDATA[Wordpress Code]]></category>
  2195. <category><![CDATA[Dynamische]]></category>
  2196. <category><![CDATA[einbinden]]></category>
  2197. <category><![CDATA[Funktion]]></category>
  2198. <category><![CDATA[Templates]]></category>
  2199. <category><![CDATA[wordpress]]></category>
  2200. <guid isPermaLink="false">https://homepage-nach-preis.de/?p=8161</guid>
  2201.  
  2202. <description><![CDATA[<p>Das &#8220;HNP Dyn Template&#8221; Plugin ermöglicht es Benutzern, zwischen verschiedenen Vorlagen für eine bestimmte Seite oder einen Beitrag zu wählen. Durch Hinzufügen von Shortcodes können Benutzer auf einfache Weise zwischen verschiedenen Templates hin- und herwechseln, ohne den Code manuell bearbeiten zu müssen. Code-Beschreibung: Shortcodes: Das Plugin fügt zwei Shortcodes hinzu: hnp_template_switcher und hnp_template_switcher_buttons. hnp_template_switcher: Dieser Shortcode rendert den Bereich, in dem das ausgewählte Template dynamisch geladen wird. Es verwendet eine PHP-Include-Anweisung, um die entsprechende Template-Datei zu laden. hnp_template_switcher_buttons: Dieser Shortcode rendert die Schaltflächen, mit denen Benutzer zwischen den verschiedenen Templates wählen können. Es gibt zwei Schaltflächen, um Template 1 und Template 2 zu laden. JavaScript: Das Plugin verwendet JavaScript, um auf Benutzerinteraktionen zu reagieren und die Templates dynamisch zu laden. Es bindet Klickereignisse an die Schaltflächen, um die entsprechenden Templates zu laden. Dazu wird eine XMLHttpRequest verwendet, um die Template-Dateien abzurufen und sie dann in den Container zu rendern. Vorteile und Nutzen: Benutzerfreundlichkeit: Das Plugin macht es einfach, zwischen verschiedenen Vorlagen zu wechseln, ohne dass Benutzer den Code bearbeiten müssen. Durch die Verwendung von Shortcodes können Benutzer die Schaltflächen und den Template-Bereich einfach in ihre Seiten und Beiträge einfügen. Flexibilität: Benutzer können verschiedene Templates erstellen und sie je nach Bedarf....</p>
  2203. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/07/dynamische-templates-in-wordpress-erzeugen-einbinden/">Dynamische Templates in WordPress erzeugen &#038; einbinden</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  2204. ]]></description>
  2205. <content:encoded><![CDATA[<p>Das &#8220;HNP Dyn Template&#8221; Plugin ermöglicht es Benutzern, zwischen verschiedenen Vorlagen für eine bestimmte Seite oder einen Beitrag zu wählen. Durch Hinzufügen von Shortcodes können Benutzer auf einfache Weise zwischen verschiedenen Templates hin- und herwechseln, ohne den Code manuell bearbeiten zu müssen.</p>
  2206. <p><strong>Code-Beschreibung:</strong></p>
  2207. <p>Shortcodes: Das Plugin fügt zwei Shortcodes hinzu: hnp_template_switcher und hnp_template_switcher_buttons.</p>
  2208. <p>hnp_template_switcher: Dieser Shortcode rendert den Bereich, in dem das ausgewählte Template dynamisch geladen wird. Es verwendet eine PHP-Include-Anweisung, um die entsprechende Template-Datei zu laden.</p>
  2209. <p>hnp_template_switcher_buttons: Dieser Shortcode rendert die Schaltflächen, mit denen Benutzer zwischen den verschiedenen Templates wählen können. Es gibt zwei Schaltflächen, um Template 1 und Template 2 zu laden.</p>
  2210. <p>JavaScript: Das Plugin verwendet JavaScript, um auf Benutzerinteraktionen zu reagieren und die Templates dynamisch zu laden. Es bindet Klickereignisse an die Schaltflächen, um die entsprechenden Templates zu laden. Dazu wird eine XMLHttpRequest verwendet, um die Template-Dateien abzurufen und sie dann in den Container zu rendern.</p>
  2211. <p><strong>Vorteile und Nutzen:</strong></p>
  2212. <p>Benutzerfreundlichkeit: Das Plugin macht es einfach, zwischen verschiedenen Vorlagen zu wechseln, ohne dass Benutzer den Code bearbeiten müssen. Durch die Verwendung von Shortcodes können Benutzer die Schaltflächen und den Template-Bereich einfach in ihre Seiten und Beiträge einfügen.</p>
  2213. <p>Flexibilität: Benutzer können verschiedene Templates erstellen und sie je nach Bedarf anpassen. Dies ermöglicht es, verschiedene Layouts und Designs für verschiedene Zwecke zu verwenden.</p>
  2214. <p>Zeitersparnis: Durch die Verwendung des Plugins können Benutzer Zeit sparen, da sie nicht jedes Mal den Code ändern müssen, wenn sie ein anderes Template verwenden möchten. Stattdessen können sie einfach die entsprechende Schaltfläche anklicken.</p>
  2215. <p><strong>Umfang:</strong></p>
  2216. <p>Das Plugin umfasst zwei Hauptkomponenten: die Shortcodes für den Template-Switcher und die zugehörige JavaScript-Funktionalität. Die Shortcodes sind einfach zu verwenden und erfordern nur minimale Konfiguration, während das JavaScript für die dynamische Laden der Templates sorgt.</p>
  2217. <p><strong>Lizenz:</strong></p>
  2218. <p>Das &#8220;HNP Dyn Template&#8221; Plugin wird unter der GNU General Public License (GPLv3) vertrieben, was bedeutet, dass es frei verwendet, modifiziert und weitergegeben werden kann, solange die Lizenzbedingungen eingehalten werden.</p>
  2219. <p><strong>Download:</strong><br />
  2220. WordPress Plugin mit Ajax: [sdm_download id=&#8221;8168&#8243; fancy=&#8221;0&#8243;]<br />
  2221. WordPress Plugin ohne Ajax: [sdm_download id=&#8221;8171&#8243; fancy=&#8221;0&#8243;]</p>
  2222. <p><strong>WordPress Plugin Code ohne Ajax (schnellere Ladezeiten):</strong></p>
  2223. <pre>&lt;?php
  2224. /*
  2225. * Plugin Name: HNP Dyn Template
  2226. * Plugin URI: https://homepage-nach-preis.de/
  2227. * Description: Erstellt 2 Button welche bei Betätigung die Template-Datei auswechseln. Shortcodes: hnp_template_switcher_buttons und hnp_template_switcher
  2228. * Version: 1.1
  2229. * Author: HNP
  2230. * Author URI: https://homepage-nach-preis.de/
  2231. * License: GPLv3
  2232. */
  2233.  
  2234. // Shortcode für den Template-Switcher hinzufügen
  2235. add_shortcode('hnp_template_switcher', 'hnp_custom_template_switcher_shortcode');
  2236.  
  2237. // Funktion zum Rendern des Shortcodes
  2238. function hnp_custom_template_switcher_shortcode() {
  2239.    ob_start();
  2240.    ?&gt;
  2241.    &lt;div id="hnp-template-container"&gt;
  2242.        &lt;!-- Hier wird das Template dynamisch geladen --&gt;
  2243.        &lt;?php include_once(plugin_dir_path(__FILE__) . '/templates/hnp_template_1.php'); ?&gt;
  2244.    &lt;/div&gt;
  2245.    &lt;?php
  2246.    return ob_get_clean();
  2247. }
  2248.  
  2249. // Shortcode für die Schaltflächen zum Wechseln der Templates hinzufügen
  2250. add_shortcode('hnp_template_switcher_buttons', 'hnp_custom_template_switcher_buttons_shortcode');
  2251.  
  2252. // Funktion zum Rendern des Shortcodes für die Schaltflächen
  2253. function hnp_custom_template_switcher_buttons_shortcode() {
  2254.    ob_start();
  2255.    ?&gt;
  2256.    &lt;button id="hnp-template1-btn"&gt;Template 1 laden&lt;/button&gt;
  2257.    &lt;button id="hnp-template2-btn"&gt;Template 2 laden&lt;/button&gt;
  2258.    &lt;?php
  2259.    return ob_get_clean();
  2260. }
  2261.  
  2262. // JavaScript zum Schalten der Templates hinzufügen
  2263. add_action('wp_footer', 'hnp_custom_template_switcher_js');
  2264.  
  2265. function hnp_custom_template_switcher_js() {
  2266.    ?&gt;
  2267.    &lt;script&gt;
  2268.    document.addEventListener('DOMContentLoaded', function() {
  2269.        document.getElementById('hnp-template1-btn').addEventListener('click', function() {
  2270.            loadTemplate('hnp_template_1.php');
  2271.        });
  2272.        document.getElementById('hnp-template2-btn').addEventListener('click', function() {
  2273.            loadTemplate('hnp_template_2.php');
  2274.        });
  2275.    });
  2276.  
  2277. function loadTemplate(templateUrl) {
  2278. var xhr = new XMLHttpRequest();
  2279. xhr.open('GET', '&lt;?php echo plugins_url("templates/", __FILE__); ?&gt;' + templateUrl, true);
  2280. xhr.onreadystatechange = function() {
  2281. if (xhr.readyState === 4 &amp;&amp; xhr.status === 200) {
  2282. document.getElementById('hnp-template-container').innerHTML = xhr.responseText;
  2283. }
  2284. };
  2285. xhr.send();
  2286. }
  2287.  
  2288.    &lt;/script&gt;
  2289.    &lt;?php
  2290. }
  2291.  
  2292. </pre>
  2293. <p><strong>Template 1 Datei:</strong></p>
  2294. <pre>&lt;?php
  2295. /*
  2296. Template Name: Template 1
  2297. */
  2298. ?&gt;
  2299.  
  2300. &lt;div class="hnp-template-content"&gt;
  2301.    &lt;h2&gt;Template 1&lt;/h2&gt;
  2302.    &lt;p&gt;Dies ist der Inhalt von Template 1.&lt;/p&gt;
  2303. &lt;/div&gt;
  2304.  
  2305. </pre>
  2306. <p><strong>Template 2 Datei:</strong></p>
  2307. <pre>&lt;?php
  2308. /*
  2309. Template Name: Template 2
  2310. */
  2311. ?&gt;
  2312.  
  2313. &lt;div class="hnp-template-content"&gt;
  2314.    &lt;h2&gt;Template 2&lt;/h2&gt;
  2315.    &lt;p&gt;Dies ist der Inhalt von Template 2.&lt;/p&gt;
  2316. &lt;/div&gt;
  2317.  
  2318. </pre>
  2319. <p><strong>WordPress Plugin Code mit Ajax:</strong></p>
  2320. <pre>&lt;?php
  2321. /*
  2322. * Plugin Name: HNP Dyn Template
  2323. * Plugin URI: https://homepage-nach-preis.de/
  2324. * Description: Erstellt 2 Button welche bei Betätigung die Template-Datei auswechseln. Shortcodes: hnp_template_switcher_buttons und hnp_template_switcher
  2325. * Version: 1.1
  2326. * Author: HNP
  2327. * Author URI: https://homepage-nach-preis.de/
  2328. * License: HNP-Dyn-Template
  2329. */
  2330.  
  2331. // Shortcode für den Template-Switcher hinzufügen
  2332. add_shortcode('hnp_template_switcher', 'hnp_custom_template_switcher_shortcode');
  2333.  
  2334. // Funktion zum Rendern des Shortcodes
  2335. function hnp_custom_template_switcher_shortcode() {
  2336.    ob_start();
  2337.    ?&gt;
  2338.    &lt;div id="hnp-template-container"&gt;
  2339.        &lt;!-- Hier wird das Template dynamisch geladen --&gt;
  2340.        &lt;?php include_once(plugin_dir_path(__FILE__) . '/templates/hnp_template_1.php'); ?&gt;
  2341.    &lt;/div&gt;
  2342.    &lt;?php
  2343.    return ob_get_clean();
  2344. }
  2345.  
  2346. // Shortcode für die Schaltflächen zum Wechseln der Templates hinzufügen
  2347. add_shortcode('hnp_template_switcher_buttons', 'hnp_custom_template_switcher_buttons_shortcode');
  2348.  
  2349. // Funktion zum Rendern des Shortcodes für die Schaltflächen
  2350. function hnp_custom_template_switcher_buttons_shortcode() {
  2351.    ob_start();
  2352.    ?&gt;
  2353.    &lt;button id="hnp-template1-btn"&gt;Template 1 laden&lt;/button&gt;
  2354.    &lt;button id="hnp-template2-btn"&gt;Template 2 laden&lt;/button&gt;
  2355.    &lt;?php
  2356.    return ob_get_clean();
  2357. }
  2358.  
  2359. // JavaScript zum Schalten der Templates hinzufügen
  2360. add_action('wp_footer', 'hnp_custom_template_switcher_js');
  2361.  
  2362. function hnp_custom_template_switcher_js() {
  2363.    wp_enqueue_script('hnp-custom-template-switcher', plugin_dir_url(__FILE__) . 'hnp_dyn_template.js', array('jquery'), null, true);
  2364.  
  2365.    wp_localize_script('hnp-custom-template-switcher', 'hnpTemplateSwitcher', array(
  2366.        'ajaxurl' =&gt; admin_url('admin-ajax.php')
  2367.    ));
  2368. }
  2369.  
  2370. // Ajax
  2371. add_action('wp_ajax_load_template', 'hnp_load_template_ajax');
  2372. add_action('wp_ajax_nopriv_load_template', 'hnp_load_template_ajax');
  2373.  
  2374. function hnp_load_template_ajax() {
  2375.    $template = isset($_GET['template']) ? $_GET['template'] : '';
  2376.  
  2377.    if ($template) {
  2378.        // Hier können Sie die Template-Datei laden und den Inhalt zurückgeben
  2379.        include(plugin_dir_path(__FILE__) . '/templates/' . $template);
  2380.    }
  2381.  
  2382.    wp_die();
  2383. }
  2384. </pre>
  2385. <p><strong>Javascript:</strong></p>
  2386. <pre>document.addEventListener('DOMContentLoaded', function() {
  2387.    document.getElementById('hnp-template1-btn').addEventListener('click', function() {
  2388.        loadTemplate('hnp_template_1.php');
  2389.    });
  2390.    document.getElementById('hnp-template2-btn').addEventListener('click', function() {
  2391.        loadTemplate('hnp_template_2.php');
  2392.    });
  2393. });
  2394.  
  2395. function loadTemplate(templateUrl) {
  2396.    var xhr = new XMLHttpRequest();
  2397.    xhr.open('GET', hnpTemplateSwitcher.ajaxurl + '?action=load_template&amp;template=' + templateUrl, true);
  2398.    xhr.onreadystatechange = function() {
  2399.        if (xhr.readyState === 4 &amp;&amp; xhr.status === 200) {
  2400.            document.getElementById('hnp-template-container').innerHTML = xhr.responseText;
  2401.        }
  2402.    };
  2403.    xhr.send();
  2404. }
  2405.  
  2406. </pre>
  2407. <p>Template Dateien hierbei identisch.</p>
  2408. <p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2024/04/07/dynamische-templates-in-wordpress-erzeugen-einbinden/">Dynamische Templates in WordPress erzeugen &#038; einbinden</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
  2409. ]]></content:encoded>
  2410. <wfw:commentRss>https://homepage-nach-preis.de/2024/04/07/dynamische-templates-in-wordpress-erzeugen-einbinden/feed/</wfw:commentRss>
  2411. <slash:comments>0</slash:comments>
  2412. </item>
  2413. </channel>
  2414. </rss>
  2415.  

If you would like to create a banner that links to this page (i.e. this validation result), do the following:

  1. Download the "valid RSS" banner.

  2. Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)

  3. Add this HTML to your page (change the image src attribute if necessary):

If you would like to create a text link instead, here is the URL you can use:

http://www.feedvalidator.org/check.cgi?url=https%3A//homepage-nach-preis.de/feed/

Copyright © 2002-9 Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda