Advertisement
MrPauloeN

Zabezpieczenie treści

May 7th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. /*
  2.  *  Zabezpieczenie treści *
  3.  *
  4.  * Jest to funkcja pomocnicza, której możesz użyć
  5.  * aby zabezpieczyć elementy na stronie inne niż treść wpisu
  6.  * np.: slider, miniaturka, itd.
  7.  *
  8.  * wstaw ją na końcu pliku funkcyjnego functions.php
  9.  */
  10.  
  11. function is_content_locker_by_wpsolucje(){
  12.    
  13.     $locker = new WPSolucje\ContentLocker\Locker( get_the_ID() );
  14.  
  15.     if  ( $locker->is_locked( true ) ) {
  16.        
  17.         return true;       
  18.     } else {   
  19.    
  20.         return false;  
  21.     }
  22. }
  23.  
  24. //Jeżeli chcesz użyć tej funkcji w kodzie, dany element należy objąć warunkiem np.:
  25.  
  26. if ( is_content_locker_by_wpsolucje() ) {
  27.  
  28. // Treść zabezpieczona
  29. } else {
  30.  
  31. // Treść odbezpieczona
  32. }
  33.  
  34. // Lub bez warunku zwrotnego:
  35.  
  36. if ( !is_content_locker_by_wpsolucje() ) {
  37.  
  38. // Treść odbezpieczona
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement