0

could anyone explain, is it possible include WP functions into Laravel blade.template?

I have WP installation and want create one folder for an app on Laravel. These functions i want include:

<?php require( '../wp-load.php' ); ?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

How i can implement this feature? Thx in advance!

1

1 Answer 1

3

1. Add WordPress to app/vendor

Download WordPress into the vendor folder (./vendor/wordpress)

User require in composer.json, see (3).

2. Find the function location

Check the Codex page for the function you need, let's say esc_url(), as you can see in that page, the function resides in wp-includes/formatting.php

3. Include the file containg the function

Include that file, use your composer.json file then run the command composer update

"require": {
    ...
    "johnpbloch/wordpress": "4.*"
},
"autoload": {
    ...
    ...
    ...
    "files": [
        ...
        "wordpress/wp-includes/formatting.php"
    ]
},

4. Use the function in Blade

{{-- file: app/views/example.blade.php }}

{{ esc_html( '<a href="http://www.example.com/">A link</a>' ) }}

This outputs:

&lt;a href=&quot;http://www.example.com/&quot;&gt;A link&lt;/a&gt;
Sign up to request clarification or add additional context in comments.

1 Comment

How can this example help me?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.