调用$ _GET ['ip']直到最近的wordpress更新,现在它已经坏了。
我不知道Wordpress如何期望我获取变量,但是我一直在搞乱并放在一起的代码似乎根本不起作用。 我显然做错了什么,但我似乎无法完成这项工作。
我正在尝试使用的代码位于:https://pastebin.com/4iipisjU
UPDATE:代码正常运行,nginx的WPSupercache配置文件似乎已经破坏了它。
答案 0 :(得分:0)
您应该可以使用get_query_var
<?php
$value = get_query_var( "paramA", "default value" );
?>
此外,$_GET['ip']
将引用作为请求的一部分传递的查询参数IP。
这实际上是你在找什么?或者您是否正在尝试查看提出请求的客户端的IP?如果是后者,这是不正确的。
答案 1 :(得分:0)
尝试将public class Productfragment extends Fragment {
private static BUser user = (BUser) ParseUser.getCurrentUser();
private enter code here
static BStore store = user.getCurrentStore();
List<BProduct> pets = new ArrayList<BProduct>();
public String [] ii;
public Productfragment(){
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return recyclerView;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.clear();
inflater.inflate(R.menu.search_menu, menu);
//super.onCreateOptionsMenu(menu, inflater);
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public SimpleDraweeView picture;
public TextView name;
public TextView description;
public ViewHolder(LayoutInflater inflater, ViewGroup parent) {
super(inflater.inflate(R.layout.productfragment, parent, false));
picture = (SimpleDraweeView) itemView.findViewById(R.id.card_image);
name = (TextView) itemView.findViewById(R.id.card_title);
// Adding Snackbar to Action Button inside card
Button button = (Button)itemView.findViewById(R.id.action_button);
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Snackbar.make(v, "Action is pressed",
Snackbar.LENGTH_LONG).show();
}
});
ImageButton favoriteImageButton =
(ImageButton) itemView.findViewById(R.id.favorite_button);
favoriteImageButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Snackbar.make(v, "Added to Favorite",
Snackbar.LENGTH_LONG).show();
}
});
ImageButton shareImageButton = (ImageButton) itemView.findViewById(R.id.share_button);
shareImageButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Snackbar.make(v, "Share article",
Snackbar.LENGTH_LONG).show();
}
});
}
}
/**
* Adapter to display recycler view.
*/
public class ContentAdapter extends RecyclerView.Adapter<ViewHolder> {
// Set numbers of Card in RecyclerView.
private static final int LENGTH = 4;
String [] mylist ;
public ContentAdapter(Context context) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Product");
// query.whereEqualTo("storeI", store.getObjectId());
query.findInBackground(new FindCallback<ParseObject>() {
// ArrayList<ParseFile>myImage = new ArrayList<ParseFile>();
public void done(List<ParseObject> scoreList, ParseException e) {
if (e == null) {
for (int i=0; i<scoreList.size(); ++i) {
mylist[i] = scoreList.get(i).getString("description");
// mylist.add(name);
}
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()), parent);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
//holder.picture.setImageURI(mPlacePictures[position % mPlacePictures.length]);
holder.name.setText(mylist[position]);
}
@Override
public int getItemCount() {
return LENGTH;
}
}
}
更改为:
$get_ip_addr