How to use same objects at wordpress admin and user side?












0















I started to create my first plugin for wordpress with admin pages and user page using OOP. At the "plugins" folder I created a new for my plugin. I have "index.php", an "includes" folder with some object php and "admin" folder. At the "themes" folder I created a new page-* php for the users. My problem, that I can't use my objects at user side. In the admin pages everything is fine, I can call and get datas, but in the page-*.php the /* @var $datas Object */ is don't do the same, $datas is NULL. How to link my admin and theme pages?
Thank for the help!










share|improve this question























  • So you are trying to access the properties of an object in the frontend of wordpress that has been instantiated in admin ?

    – Jamie_D
    Nov 20 '18 at 12:59













  • Yes. In the plugin folder have an includes folder (with classes and admin). The object created/edited in the admin main file. Maybe I put the classes into the themes folder? I don't know yet wordpress structure what what can see.

    – Galtomasz
    Nov 20 '18 at 13:21











  • Generally, a plugin is simply an extension of your theme's functions.php file, so any object that resides (and is included) in your plugin will be accessible in your frontend theme, provided you instantiate it. See Initiate a class in a WP plugin

    – Jamie_D
    Nov 20 '18 at 13:40











  • The problem with this class call, that I don't need the functions in the class now. I have only a construct and some getter functions. I need the final object which content is the sql table all data. This created in the admin file with $images = new Photos(id, param1, param2, param3,... ); uploadPhotos($images);. For list data $images = getPhotos(); get the data with sql query. After this I would like to use a foreach $images as $image and get values by $image->getParam().

    – Galtomasz
    Nov 20 '18 at 14:13











  • Please post your class code.

    – Jamie_D
    Nov 20 '18 at 14:36
















0















I started to create my first plugin for wordpress with admin pages and user page using OOP. At the "plugins" folder I created a new for my plugin. I have "index.php", an "includes" folder with some object php and "admin" folder. At the "themes" folder I created a new page-* php for the users. My problem, that I can't use my objects at user side. In the admin pages everything is fine, I can call and get datas, but in the page-*.php the /* @var $datas Object */ is don't do the same, $datas is NULL. How to link my admin and theme pages?
Thank for the help!










share|improve this question























  • So you are trying to access the properties of an object in the frontend of wordpress that has been instantiated in admin ?

    – Jamie_D
    Nov 20 '18 at 12:59













  • Yes. In the plugin folder have an includes folder (with classes and admin). The object created/edited in the admin main file. Maybe I put the classes into the themes folder? I don't know yet wordpress structure what what can see.

    – Galtomasz
    Nov 20 '18 at 13:21











  • Generally, a plugin is simply an extension of your theme's functions.php file, so any object that resides (and is included) in your plugin will be accessible in your frontend theme, provided you instantiate it. See Initiate a class in a WP plugin

    – Jamie_D
    Nov 20 '18 at 13:40











  • The problem with this class call, that I don't need the functions in the class now. I have only a construct and some getter functions. I need the final object which content is the sql table all data. This created in the admin file with $images = new Photos(id, param1, param2, param3,... ); uploadPhotos($images);. For list data $images = getPhotos(); get the data with sql query. After this I would like to use a foreach $images as $image and get values by $image->getParam().

    – Galtomasz
    Nov 20 '18 at 14:13











  • Please post your class code.

    – Jamie_D
    Nov 20 '18 at 14:36














0












0








0








I started to create my first plugin for wordpress with admin pages and user page using OOP. At the "plugins" folder I created a new for my plugin. I have "index.php", an "includes" folder with some object php and "admin" folder. At the "themes" folder I created a new page-* php for the users. My problem, that I can't use my objects at user side. In the admin pages everything is fine, I can call and get datas, but in the page-*.php the /* @var $datas Object */ is don't do the same, $datas is NULL. How to link my admin and theme pages?
Thank for the help!










share|improve this question














I started to create my first plugin for wordpress with admin pages and user page using OOP. At the "plugins" folder I created a new for my plugin. I have "index.php", an "includes" folder with some object php and "admin" folder. At the "themes" folder I created a new page-* php for the users. My problem, that I can't use my objects at user side. In the admin pages everything is fine, I can call and get datas, but in the page-*.php the /* @var $datas Object */ is don't do the same, $datas is NULL. How to link my admin and theme pages?
Thank for the help!







php wordpress






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 10:54









GaltomaszGaltomasz

1




1













  • So you are trying to access the properties of an object in the frontend of wordpress that has been instantiated in admin ?

    – Jamie_D
    Nov 20 '18 at 12:59













  • Yes. In the plugin folder have an includes folder (with classes and admin). The object created/edited in the admin main file. Maybe I put the classes into the themes folder? I don't know yet wordpress structure what what can see.

    – Galtomasz
    Nov 20 '18 at 13:21











  • Generally, a plugin is simply an extension of your theme's functions.php file, so any object that resides (and is included) in your plugin will be accessible in your frontend theme, provided you instantiate it. See Initiate a class in a WP plugin

    – Jamie_D
    Nov 20 '18 at 13:40











  • The problem with this class call, that I don't need the functions in the class now. I have only a construct and some getter functions. I need the final object which content is the sql table all data. This created in the admin file with $images = new Photos(id, param1, param2, param3,... ); uploadPhotos($images);. For list data $images = getPhotos(); get the data with sql query. After this I would like to use a foreach $images as $image and get values by $image->getParam().

    – Galtomasz
    Nov 20 '18 at 14:13











  • Please post your class code.

    – Jamie_D
    Nov 20 '18 at 14:36



















  • So you are trying to access the properties of an object in the frontend of wordpress that has been instantiated in admin ?

    – Jamie_D
    Nov 20 '18 at 12:59













  • Yes. In the plugin folder have an includes folder (with classes and admin). The object created/edited in the admin main file. Maybe I put the classes into the themes folder? I don't know yet wordpress structure what what can see.

    – Galtomasz
    Nov 20 '18 at 13:21











  • Generally, a plugin is simply an extension of your theme's functions.php file, so any object that resides (and is included) in your plugin will be accessible in your frontend theme, provided you instantiate it. See Initiate a class in a WP plugin

    – Jamie_D
    Nov 20 '18 at 13:40











  • The problem with this class call, that I don't need the functions in the class now. I have only a construct and some getter functions. I need the final object which content is the sql table all data. This created in the admin file with $images = new Photos(id, param1, param2, param3,... ); uploadPhotos($images);. For list data $images = getPhotos(); get the data with sql query. After this I would like to use a foreach $images as $image and get values by $image->getParam().

    – Galtomasz
    Nov 20 '18 at 14:13











  • Please post your class code.

    – Jamie_D
    Nov 20 '18 at 14:36

















So you are trying to access the properties of an object in the frontend of wordpress that has been instantiated in admin ?

– Jamie_D
Nov 20 '18 at 12:59







So you are trying to access the properties of an object in the frontend of wordpress that has been instantiated in admin ?

– Jamie_D
Nov 20 '18 at 12:59















Yes. In the plugin folder have an includes folder (with classes and admin). The object created/edited in the admin main file. Maybe I put the classes into the themes folder? I don't know yet wordpress structure what what can see.

– Galtomasz
Nov 20 '18 at 13:21





Yes. In the plugin folder have an includes folder (with classes and admin). The object created/edited in the admin main file. Maybe I put the classes into the themes folder? I don't know yet wordpress structure what what can see.

– Galtomasz
Nov 20 '18 at 13:21













Generally, a plugin is simply an extension of your theme's functions.php file, so any object that resides (and is included) in your plugin will be accessible in your frontend theme, provided you instantiate it. See Initiate a class in a WP plugin

– Jamie_D
Nov 20 '18 at 13:40





Generally, a plugin is simply an extension of your theme's functions.php file, so any object that resides (and is included) in your plugin will be accessible in your frontend theme, provided you instantiate it. See Initiate a class in a WP plugin

– Jamie_D
Nov 20 '18 at 13:40













The problem with this class call, that I don't need the functions in the class now. I have only a construct and some getter functions. I need the final object which content is the sql table all data. This created in the admin file with $images = new Photos(id, param1, param2, param3,... ); uploadPhotos($images);. For list data $images = getPhotos(); get the data with sql query. After this I would like to use a foreach $images as $image and get values by $image->getParam().

– Galtomasz
Nov 20 '18 at 14:13





The problem with this class call, that I don't need the functions in the class now. I have only a construct and some getter functions. I need the final object which content is the sql table all data. This created in the admin file with $images = new Photos(id, param1, param2, param3,... ); uploadPhotos($images);. For list data $images = getPhotos(); get the data with sql query. After this I would like to use a foreach $images as $image and get values by $image->getParam().

– Galtomasz
Nov 20 '18 at 14:13













Please post your class code.

– Jamie_D
Nov 20 '18 at 14:36





Please post your class code.

– Jamie_D
Nov 20 '18 at 14:36












1 Answer
1






active

oldest

votes


















0














Thanks for Jamie-D, I can solve my problem. I can't reach the original object in admin side, but I created a same structure as in admin and call the same functions. With this I created a new variable for the object, which contain the same data as the original, because both use the same database.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391441%2fhow-to-use-same-objects-at-wordpress-admin-and-user-side%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Thanks for Jamie-D, I can solve my problem. I can't reach the original object in admin side, but I created a same structure as in admin and call the same functions. With this I created a new variable for the object, which contain the same data as the original, because both use the same database.






    share|improve this answer




























      0














      Thanks for Jamie-D, I can solve my problem. I can't reach the original object in admin side, but I created a same structure as in admin and call the same functions. With this I created a new variable for the object, which contain the same data as the original, because both use the same database.






      share|improve this answer


























        0












        0








        0







        Thanks for Jamie-D, I can solve my problem. I can't reach the original object in admin side, but I created a same structure as in admin and call the same functions. With this I created a new variable for the object, which contain the same data as the original, because both use the same database.






        share|improve this answer













        Thanks for Jamie-D, I can solve my problem. I can't reach the original object in admin side, but I created a same structure as in admin and call the same functions. With this I created a new variable for the object, which contain the same data as the original, because both use the same database.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 9:42









        GaltomaszGaltomasz

        1




        1
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391441%2fhow-to-use-same-objects-at-wordpress-admin-and-user-side%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)