PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/link-adder_add.php

https://github.com/koggdal/link-adder
PHP | 22 lines | 15 code | 2 blank | 5 comment | 7 complexity | 60e27d0b0b77dfe3063c7296480f60c6 MD5 | raw file
  1. <?php
  2. /* Only go further if both title and URLs are set and not empty */
  3. if(isset($_GET['title']) && isset($_GET['url']) && !empty($_GET['title']) && !empty($_GET['url']))
  4. {
  5. /* Include the WordPress files to be able to access the right methods */
  6. include_once('../../../wp-config.php');
  7. include_once('../../../wp-admin/includes/bookmark.php');
  8. /* Only run if the hash is correct (unique hash for each WP install) */
  9. $option_hash = get_option('link-adder-id');
  10. if(!empty($option_hash) && $option_hash == $_GET['hash'])
  11. {
  12. /* Fetch the values */
  13. $title = $_GET['title'];
  14. $url = $_GET['url'];
  15. $description = isset($_GET['description']) ? $_GET['description'] : "";
  16. /* Add the link to the database */
  17. wp_insert_link(array("link_name"=>$title,"link_url"=>$url,"link_description"=>$description));
  18. }
  19. }
  20. ?>