soeintyp
Verfasste Forenbeiträge
-
Forum: Plugins
Als Antwort auf: Permalink wird zum href hinzugefügtIst jetzt geändert:
public function getFileDownloadPath() { $folder = '/files/'; $path = ABSPATH . $folder; $download = $_SERVER["HTTP_HOST"] . $folder; $return = null; if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $return .= "<a href='https://$download$entry' download=''>$entry</a><br>"; } } return $return; closedir($handle); } }
Und ja, das ist natürlich kein valides HTML. Aber ist ja auch noch nicht produktiv. 😉
Mitreturn
und angabe vonhttps
hat es jetzt funktioniert.Ich kann es mir zwar nicht erklären, aber WordPress ist so oder so nicht meine Welt.
Vielen Dank für die kompetente Hilfe!
- Diese Antwort wurde geändert vor 3 Jahren, 10 Monaten von soeintyp.
Forum: Plugins
Als Antwort auf: Permalink wird zum href hinzugefügt1. ich gebe mehrere Werte aus, deshalb
echo
. Mitreturn
wird die function beendet.
2.get_site_url
ist an WP gebunden, meine Variante nicht.
3. Ich fang nochmal von vorne an.Ich erstelle einen Shortcode um auf eine bestimmten Seite meine PHP Funktion zu laden. In dieser PHP Funktion wird der Inhalt eines Ordners aufgelistet ausgegeben. Nun soll wenn man auf eins der Elemente klickt zum download weitergeleitet werden.
Im HTML wird folgenes ausgegeben:
<a href="www.DOMAIN.com/files/Information zur Lagerung unserer Produkte.pdf" download="">Information zur Lagerung unserer Produkte.pdf</a>
Absolut korrekt und einwandfrei. Jetzt das Problem:
Beim Hovern auf das A-Tag wird mir der Permalink noch zusätzlich vor meinem Link angezeigt.Ich gehe also in die DevTools und gucke mir den Code an:
<a href="www.DOMAIN.com/files/Information zur Lagerung unserer Produkte.pdf" download="">Information zur Lagerung unserer Produkte.pdf</a>
Ich schließe die DevTools und hovere über den Link sieht es so aus:
BeispiellinkDer Code funktioniert ohne WordPress einwandfrei, es scheint mir so als würde WordPress vor jedes Href den Permalink knallen..
Forum: Plugins
Als Antwort auf: Permalink wird zum href hinzugefügtAber natürlich. Wie gesagt es funktioniert ja soweit, nur bei der Einbindung in WP wird der Permalink dem href hinzugefügt.
$start_ftp_alternative = new FtpAlternative(); /** * Class FtpAlternative */ class FtpAlternative{ public function __construct() { register_activation_hook( __FILE__, array( $this, 'ftpAlternative_activate' ) ); $this->make_shortcode(); } /** * Display filepath * * @param $path */ public function getFileDownloadPath() { $folder = '/files/'; $path = ABSPATH . $folder; $download = $_SERVER["HTTP_HOST"] . $folder; if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { echo "<a href='$download$entry' download=''>$entry</a><br>"; } } closedir($handle); } } /** * Create shortcodes * [getFileDownloadPath] */ function make_shortcode() { add_shortcode('getFileDownloadPath', array($this,'getFileDownloadPath')); } }