How to use same objects at wordpress admin and user side?
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
|
show 13 more comments
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
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
|
show 13 more comments
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
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
php wordpress
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
|
show 13 more comments
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
|
show 13 more comments
1 Answer
1
active
oldest
votes
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 21 '18 at 9:42
GaltomaszGaltomasz
1
1
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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